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

how do i check if a variable has changed? [closed]

Asked by 4 years ago

This question already has an answer here:

Is there a way to have any variable have a 'Changed' event?

So Im trying to make it so that when a variable changes

it fires something

for instance

Var = 0



--if it changes do something here




0
i dont think there's a direct way but u can fire a different function every time it changes like Var = 1 function() HappyTimIsHim 652 — 4y
0
lul i know a slightly better way than a while loop SoftlockedUnderZero 668 — 4y

Marked as Duplicate by JakyeRU and hiimgoodpack

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

3 answers

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

For Values

script.Parent.Value.Changed:Connect(function(changed)
--Do whatever
end)

or

For Variables

while true do
    wait()
    if variable == true then
        --Do whatever
        return
    end
end
Ad
Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
4 years ago

With physical values, do this:

local Value = script.Parent
Value.Changed:Connect(function()
    --Thing here
end
Log in to vote
-1
Answered by
D3VRO 66
4 years ago

You could use a print statement and the GetPropertyChangedSignal event.

0
um he meant for variables not instances SoftlockedUnderZero 668 — 4y
0
Well. The guy did say for instance in his post Lakodex 711 — 4y
0
with that 'for instance' he means 'for example' aprilsfooled 29 — 4y