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

Why won't my brick change to the correct colour?

Asked by
OhNope 6
5 years ago

I'm currently making a jail cell which has a button outside the door. Once someone is placed inside the cell, you press the button to make a brick above the door turn green/red depending on whether the cell is occupied or not.

This is the script I have so far:

local button = script.Parent
local light = game.Workspace.light


button.ClickDetector.MouseClick:Connect(function(occupied)
    light.PointLight.Color = Color3.new(255,0,0)
    light.Color = Color3.new(196,40,28)
end)


button.ClickDetector.MouseClick:Connect(function(vacant)
    light.PointLight.Color = Color3.new(0,255,0)
    light.Color = Color3.new(75,151,75)
end)

So far the script somewhat works. When I click the button, it changes the pointlight colour to red, but the actual brick colour is changed to 60, 216, 228 - Teal. I don't understand why it is changing it to that colour. If I click the button again, nothing happens, but I would like it to change back to green.

1
Replace all of your color3.new()'s to color3.fromRGB(). Also, your system wont quite work. You need to use an if statment to check the current status of the button, then go from there. mc3334 649 — 5y
0
I don't think Color is correct. I think if it's a block, the word shouldn't be 'Color', but instead, 'BrickColor' LennyPlayzYT 269 — 5y

Answer this question