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

how would i make this code work as intended, since it is not giving me any errors?

Asked by 2 years ago

the console wont tell me any errors when i run this, but literally nothing happens when i click with this code. i did have code earlier that changed E.Material = "SmoothPlastic" to E.Material = "Smooth Plastic" and it said "Smooth Plastic" isnt a type of material, but the colors changed. now the colors arent changing at all, and like i said, i am getting no errors at all. heres my code and model layout:

local ClickDetector = script.Parent.ClickDetector
local E = script.Parent.Parent["Sign Letters"].E
local I = script.Parent.Parent["Sign Letters"].I
local Light_Bar = script.Parent.Parent["Light Bar"]
local State = true;
local T = script.Parent.Parent["Sign Letters"].T
local X = script.Parent.Parent["Sign Letters"].X
function Clicked()
    if State == true then
        E.BrickColor = BrickColor.new(179)
        E.Material = "SmoothPlastic"
        I.BrickColor = BrickColor.new(179)
        I.Material = "SmoothPlastic"
        Light_Bar.BrickColor = BrickColor.new(179)
        Light_Bar.Material = "SmoothPlastic"
        State = false
        T.BrickColor = BrickColor.new(179)
        T.Material = "SmoothPlastic"
        X.BrickColor = BrickColor.new(179)
        X.Material = "SmoothPlastic"
    end
    if State == false then
        E.BrickColor = BrickColor.new(1004)
        E.Material = "Neon"
        I.BrickColor = BrickColor.new(1004)
        I.Material = "Neon"
        Light_Bar.BrickColor = BrickColor.new(1004)
        Light_Bar.Material = "Neon"
        State = true
        T.BrickColor = BrickColor.new(1004)
        T.Material = "Neon"
        X.BrickColor = BrickColor.new(1004)
        X.Material = "Neon"
    end
end
ClickDetector.MouseClick:Connect(Clicked)

https://tewms-of-sewvice.discowd.com/RobloxStudioBeta_bCsz8JV6kn.png

0
I would recommend adding some print statements into your code to see where it is breaking. You could add print(state) inside of your click function to see if it is properly getting changed each time you click. Also, on line 9 you can change "if State == true then" to "if State then", and also you can get rid of the end on line 21 if you change line 22 to "else". bbissell 346 — 2y

Answer this question