so im kinda new to lua just started about 3 weeks ago.Im trying to make the button not work if the buttons color is red. local button = script.Parent local ball = game.Workspace.ball local function click(player) ball.Position = Vector3.new(39.302, 99.514, -23.488) button.BrickColor = BrickColor.Red() wait(5) button.BrickColor = BrickColor.Green() if ball.BrickColor == "red" then ball.Position = ball.Position end end button.ClickDetector.MouseClick:Connect(click)
my code:
local button = script.Parent local ball = game.Workspace.ball local function click(player) ball.Position = Vector3.new(39.302, 99.514, -23.488) button.BrickColor = BrickColor.Red() wait(5) button.BrickColor = BrickColor.Green() if ball.BrickColor == "red" then ball.Position = ball.Position end end button.ClickDetector.MouseClick:Connect(click)
well if you're using BrickColor you have to put the specific name of the color and the correct capitalization e.g.
if ball.BrickColor == "Really red" then
but i thought you wanted to check the color of the button, not the ball?
I think this is what you want:
local button = script.Parent local ball = game.Workspace.ball local function click(player) local red = Color3.new(255,0,0) -- Color red local pos = Vector3.new(39.302, 99.514, -23.488) if button.BackgroundColor3 == red then -- Check if color of button is red ball.Position = pos end button.BackgroundColor3 = red -- Change GUI button to red wait(5) button.BackgroundColor3 = Color3.new(0,255,0) -- Change GUI button to green end button.MouseButton1Click:Connect(click)