Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make GUI button that changes properties of a part?

Asked by 6 years ago

I'm trying to learn scripting. So I decided to train myself by making a GUI button that changes part called Red into green color then into really red color. But for some reason, it doesn't work.

local light = game.workspace.Lights

function onClicked()
    light.Red.BrickColor = BrickColor.new(Green) 
    wait(3)
    light.Red.BrickColor = BrickColor.new(Really red) 
end

script.Parent.TextButton.MouseButton1Down:connect(onClicked)

What have I done wrong in this?

1 answer

Log in to vote
0
Answered by 6 years ago

You have to put speech marks like this.

local light = game.Workspace.Lights

function onClicked()
       light.Red.BrickColor = BrickColor.new("Lime green") --You need speech marks to make it work.
       wait(3)
       light.Red.BrickColor = BrickColor.new("Really red") --You need speech marks to make it work.
end


script.Parent.TextButton.MouseButton1Down:connect(onClicked)
Ad

Answer this question