Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

3 comments

1

try doing game.Lighting.skyColor3:GetPropertyChangedSignal("Value"):Connect(changeSkyColor)

0

@WizyTheNinja didn't seem to help, it still doesn't change the color

0

Is skycolor3 a value in lighting?

1 answer

✓ Accepted answer

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! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.