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

Trying to make a Color3 change based off another Color3 using .Changed, but its not working?

Asked by 3 years ago

I have a script in some lights that copy a Color3 value that is a child of Lighting. The code to do so is here:

function changeSkyColor()
    script.Parent.Color = game.Lighting.skyColor3.Value --in this case, script.Parent is a SurfaceLight
end

game.Lighting.skyColor3.Value.Changed:Connect(changeSkyColor)

However, when skyColor3.Value changes, the color of the lights im trying to change don't change. Any help?

1
try doing game.Lighting.skyColor3:GetPropertyChangedSignal("Value"):Connect(changeSkyColor) WizyTheNinja 834 — 3y
0
@WizyTheNinja didn't seem to help, it still doesn't change the color MrAwesomeOwl_47 9 — 3y
0
Is skycolor3 a value in lighting? Golden_Tyler115 54 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hello, MrAwesomeOwl_47! I think I found out why your script isn't working.

You cannot check if the value has changed by doing: "game.Lighting.skyColor3.Value.Changed" There's 2 ways to see if the value has changed the second one is a bit harder and I think it would be better for you to use the first way so I'm only going to show you the first way. In the first way you can only check when the skyColor3 has changed not the skyColor3.Value has changed, what this means is the function will be fired when any property in the value changes. But the script will still work perfectly. Here's the script:

function changeSkyColor()
    script.Parent.Color = game.Lighting.skyColor3.Value --in this case, script.Parent is a SurfaceLight
end

game.Lighting.skyColor3.Changed:Connect(changeSkyColor)

I've tested it so it should perfectly! Hope this can help! Good luck! :)

Ad

Answer this question