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

Weird issue with IntValue. Script turning on when it isn't suppose to. Anyone know the issue?

Asked by
ghxstlvty 133
3 years ago

I made a remote event, when this gui button is pushed it will turn on the the LeftArrow lights on a police lightbar. The lights are controlled by script 1 below. When the remote event is fired by clicking a button it fires a server script which changes the IntValue (on) to 11. This turns on the script below, but it also enables the RightArrow lights, but I have no idea how or why it does this. The script for the RightArrow is found below (script 2). RightArrow should turn on when the value is 10 but instead turns on when the value is 11.

1

while true do
    wait()
    if script.Parent.on.Value == 11 then
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 1
        wait(.2)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.2)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.2)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.2)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.4)
    else
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
    end
end

2

while true do
    wait()
    if script.Parent.on.Value == 10 then
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 1
        wait(.35)
        script.Parent.B1AMBER.Transparency = 0
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.35)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 0
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.2)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 0
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.2)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 0
        script.Parent.B4AMBER.Transparency = 0
        wait(.2)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 0
        wait(.2)
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
        wait(.4)
    else
        script.Parent.B1AMBER.Transparency = 1
        script.Parent.B2AMBER.Transparency = 1
        script.Parent.BO1AMBER.Transparency = 1
        script.Parent.B3AMBER.Transparency = 1
        script.Parent.B4AMBER.Transparency = 1
    end
end
0
What do you mean by "turning on?" JesseSong 3916 — 3y
0
It will make the lights light up ghxstlvty 133 — 3y
1
Just a minor nitpick, you should be using GetPropertyChangedSignal instead of a while loop. radiant_Light203 1166 — 3y
0
I don't think I do, I don't know how thats used and every video I watch does not use that. ghxstlvty 133 — 3y

Answer this question