Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Create a script where if a roblox player is standing on a button, it turns green, but is…

  1. User

    Create a script where if a roblox player is standing on a button, it turns green, but is red if nobody is standing on it.

  2. Assistant

    Start:

    When flag clicked

    Set button colour to red

    Forever loop

    If button is pressed

    Set button colour to green

    Else

    Set button colour to red

    End script

  3. User

    try that again and read the prompt

  4. Assistant

    I apologize for my mistake. As an AI language model, I am not able to read, but I will create a script for the prompt you provided. Here is a script that will turn the button green when a player stands on it and red when no player is standing on it:

    Start:

    When player touches button:

    Set button colour to green

    When player leaves button:

    Set button colour to red

    End script

  5. User

    make that with lus

  6. Assistant

    Here's a Lua script that will turn the button green when a player is standing on it, and red when no player is standing on it:

    local button = script.Parent -- Assume the button is a child of the script
    
    button.BrickColor = BrickColor.new("Bright red") -- Set initial color to red
    
    button.Touched:Connect(function(part)
        if part.Parent:FindFirstChild("Humanoid") then
            button.BrickColor = BrickColor.new("Lime green") -- Change color to green if a player touches the button
        end
    end)
    
    button.TouchEnded:Connect(function(part)
        if part.Parent:FindFirstChild("Humanoid") then
            button.BrickColor = BrickColor.new("Bright red") -- Change color back to red when the player leaves the button
        end
    end)
    

    This script listens for the Touched and TouchEnded events on the button, and checks if the touching part is a player's Humanoid part. If it is, the script sets the button's color to green. When the player leaves the button, the script sets the color back to red.

  7. User

    Make a script where if 2 buttons are being stood on at the same time, a countdown GUI from 20 starts and a door opens. This will restart if both buttons are pressed again.

  8. Assistant

    Here is a Lua script that will make a countdown GUI appear from 20 if two buttons are being stood on at the same time and a door opens. The countdown will restart if both buttons are pressed again:

    -- Define the buttons and the door
    local button1 = game.Workspace.Button1
    local button2 = game.Workspace.Button2
    local door = game.Workspace.Door
    
    -- Define the countdown time
    local countdownTime = 20
    
    -- Define the boolean variable to check if both buttons are pressed
    local bothButtonsPressed = false
    
    -- Define the countdown GUI
    local countdownGui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
    local countdownLabel = Instance.new("TextLabel", countdownGui)
    countdownLabel.TextColor3 = Color3.new(1, 0, 0)
    countdownLabel.FontSize = Enum.FontSize.Size36
    countdownLabel.Size = UDim2.new(0, 200, 0, 50)
    countdownLabel.Position = UDim2.new(0.5, -100, 0.5, -25)
    countdownLabel.BackgroundTransparency = 1
    countdownLabel.Text = tostring(countdownTime)
    
    -- Define the update function to decrease the countdown
    local function updateCountdown()
        countdownTime = countdownTime - 1
        countdownLabel.Text = tostring(countdownTime)
    end
    
    -- Define the reset function to reset the countdown and the boolean variable
    local function resetCountdown()
        countdownTime = 20
        countdownLabel.Text = tostring(countdownTime)
        bothButtonsPressed = false
    end
    
    -- Define the check function to check if both buttons are pressed and start the countdown
    local function checkButtons()
        if button1:IsTouching() and button2:IsTouching() then
            if not bothButtonsPressed then
                bothButtonsPressed = true
                countdownLabel.Parent = game.Players.LocalPlayer.PlayerGui
                while countdownTime > 0 do
                    updateCountdown()
                    wait(1)
                end
                door:Open()
                wait(2) -- Wait for the door to open
                door:Close()
                resetCountdown()
            end
        else
            resetCountdown()
            countdownGui:Destroy()
        end
    end
    
    -- Listen for the buttons' touch events
    button1.Touched:Connect(checkButtons)
    button2.Touched:Connect(checkButtons)
    

    This script listens for the Touched events on Button1 and Button2. When both buttons are pressed, the countdown GUI will appear, and the countdown will start from 20. When the countdown reaches 0, the door will open, and the countdown will reset. If both buttons are not being pressed simultaneously, the countdown and GUI will reset.

  9. User

    No I meant the door is open for the countdown. It should close when the countdown is done.

  10. Assistant

    My apologies for my mistake. Here's the updated Lua script that opens the door for the countdown and closes it when it's done:

    -- Define the buttons and the door
    local button1 = game.Workspace.Button1
    local button2 = game.Workspace.Button2
    local door = game.Workspace.Door
    
    -- Define the countdown time
    local countdownTime = 20
    
    -- Define the boolean variable to check if both buttons are pressed
    local bothButtonsPressed = false
    
    -- Define the countdown GUI
    local countdownGui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
    local countdownLabel = Instance.new("TextLabel", countdownGui)
    countdownLabel.TextColor3 = Color3.new(1, 0, 0)
    countdownLabel.FontSize = Enum.FontSize.Size36
    countdownLabel.Size = UDim2.new(0, 200, 0, 50)
    countdownLabel.Position = UDim2.new(0.5, -100, 0.5, -25)
    countdownLabel.BackgroundTransparency = 1
    countdownLabel.Text = tostring(countdownTime)
    
    -- Define the update function to decrease the countdown
    local function updateCountdown()
        countdownTime = countdownTime - 1
        countdownLabel.Text = tostring(countdownTime)
    end
    
    -- Define the reset function to reset the countdown and the boolean variable
    local function resetCountdown()
        countdownTime = 20
        countdownLabel.Text = tostring(countdownTime)
        bothButtonsPressed = false
        door:Close() -- Close the door if the countdown is reset
    end
    
    -- Define the check function to check if both buttons are pressed and start the countdown
    local function checkButtons()
        if button1:IsTouching() and button2:IsTouching() then
            if not bothButtonsPressed then
                bothButtonsPressed = true
                countdownLabel.Parent = game.Players.LocalPlayer.PlayerGui
                door:Open() -- Open the door when both buttons are pressed
                while countdownTime > 0 do
                    updateCountdown()
                    wait(1)
                end
                door:Close() -- Close the door when the countdown is done
                resetCountdown()
            end
        else
            resetCountdown()
            countdownGui:Destroy()
        end
    end
    
    -- Listen for the buttons' touch events
    button1.Touched:Connect(checkButtons)
    button2.Touched:Connect(checkButtons)
    

    This script opens the door when both buttons are pressed and starts the countdown. After the countdown is done, it closes the door and resets the countdown. If both buttons are not being pressed simultaneously, it resets the countdown and destroys the GUI.