Hi,
I want to script a traffic light. However, my script doesn’t work the way it should. However, my script doesn’t work the way it should. The light /decals should react to the Nuber Value in NumVal. The light /decals should react to the Nuber Value in NumVal. However, they don’t. I used a clickdetector for testing, which sets the NumVal from 1 to 2. You can find the scripts below.
function changeLight()
local rot = script.Parent.Rot
local orange = script.Parent.Orange
local gruen = script.Parent.Gruen
local Value = script.Parent.NumVal.Value
wait()
if Value == 1 then
rot.Decal.Transparency = 0
rot.PointLight.Enabled = true
orange.Decal.Transparency = 1
orange.PointLight.Enabled = false
gruen.Decal.Transparency = 1
gruen.PointLight.Enabled = false
elseif Value == 2 then
rot.Decal.Transparency = 0
rot.PointLight.Enabled = true
orange.Decal.Transparency = 0
orange.PointLight.Enabled = true
gruen.Decal.Transparency = 1
gruen.PointLight.Enabled = false
elseif Value == 3 then
rot.Decal.Transparency = 1
rot.PointLight.Enabled = false
orange.Decal.Transparency = 1
orange.PointLight.Enabled = false
gruen.Decal.Transparency = 0
gruen.PointLight.Enabled = true
elseif Value == 4 then
rot.Decal.Transparency = 1
rot.PointLight.Enabled = false
orange.Decal.Transparency = 0
orange.PointLight.Enabled = true
gruen.Decal.Transparency = 1
gruen.PointLight.Enabled = false
end
end
script.Parent.NumVal:GetAttributeChangedSignal("Value"):Connect(changeLight())
Script from the traffic lights.
local Value = script.Parent.Parent.Parent.NumVal.Value
script.Parent.MouseClick:Connect(function()
Value = 2
print(Value)
end)
Script from the Button. The button shouldn’t have an error.
Thank you for your help
Pino