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

.Changed On Variables?

Asked by
Vezious 310 Moderation Voter
8 years ago

Does this work?

local Time = 0
Time.Changed:connect(function()
Print("Time Changed")
end

1 answer

Log in to vote
0
Answered by
Legojoker 345 Moderation Voter
8 years ago

No, you can not use a Changed listening event on variables inside your script, unlike userdata. The reason for this is because roblox figures if you ever change a value and want something to happen with that change, you will make a function to be called for it. For example:

local Time = 0

function ChangeTime(val)
    Time = val
    print("Time Changed")
end

so instead of saying Time = whatever value, you say ChangeTime(whatever value)

0
Problem Is, I have a coroutine event that will fire when The Game Has Started. But The Game Has Started is a variable. how can I do this? Vezious 310 — 8y
0
Use the same variable for the Game has started. You call the Game Has Started coroutine when you see the value change OR when you're about to change the value, and then have the coroutine have it do that for you + run the code. Legojoker 345 — 8y
Ad

Answer this question