hi, I am making a light bar, but I have a problem.
the issue is that when I change activated (boolean value)'s value to true, the lights don't flash!
I can tell by that I don't get "cool" on line 8 in output.
the script is in 1x2 light text (or block).
the activated bool value is in 1x2 light text (or block).
there is no error!
.changed that does not work is on line 60!
script:
---shortcuts local block = script.Parent local light = block.PointLight local activate = block.activated ---function switch function switch() print("cool") ---if activated is true if activate.Value == true then ---change transparency block.Transparency = 0 ---activate light light.Enabled = true ---change material block.Material = Enum.Material.Neon ---loop while activate.Value == true do ---change color of block and light block.BrickColor = BrickColor.Red() light.Color = Color3.fromRGB(255, 0, 0) ---wait wait(math.random(1, 20) / 10) ---change color of block and light block.BrickColor = BrickColor.Blue() light.Color = Color3.fromRGB(0, 0, 255) ---wait wait(math.random(1, 20) / 10) end end ---if activated is false if activate.Value == false then ---change transparency block.Transparency = 0.5 ---change material block.Material = Enum.Material.Glass ---de-activate light light.Enabled = false ---change color of block and light block.BrickColor = BrickColor.White() light.Color = Color3.fromRGB(255, 255, 255) end end ---triggers activate.Changed:Connect(switch)
One problem I noticed; You didn't even put anything to change the Value of the boolean. Try experimenting with these:
---shortcuts local block = script.Parent local light = block.PointLight local activate = block.activated ---function switch function switch() print("cool") ---if activated is true if activate.Value == true then ---change transparency block.Transparency = 0 ---activate light light.Enabled = true ---change material block.Material = Enum.Material.Neon ---loop while activate.Value == true do ---change color of block and light block.BrickColor = BrickColor.Red() light.Color = Color3.fromRGB(255, 0, 0) ---wait wait(math.random(1, 20) / 10) ---change color of block and light block.BrickColor = BrickColor.Blue() light.Color = Color3.fromRGB(0, 0, 255) ---wait wait(math.random(1, 20) / 10) end end ---if activated is false if activate.Value == false then ---change transparency block.Transparency = 0.5 ---change material block.Material = Enum.Material.Glass ---de-activate lights light.Enabled = false ---change color of block and light block.BrickColor = BrickColor.White() light.Color = Color3.fromRGB(255, 255, 255) end end ---triggers block.Touched:Connect(function(hit) activate.Value = not activate.Value end) activate.Changed:Connect(switch)
The script is listening for any changes in the property of activate. But you didn't do anything to change properties, therefore the script is not doing anything.