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

How can you detect if a variable has changed?

Asked by
Memotag 226 Moderation Voter
4 years ago

I've made a script that runs whenever a player respawns that checks for a particular value which is used to assign a variable and I'm wondering if it is at all possible to be able to tell the script that this value has been updated and to run through itself again to change said variable?

I've looked into using callbacks but I'm still not sure how exactly they work so an explanation on it too would be greatly appreciated.

0
IntValue:GetPropertyChangedSignal("Name"):Connect(someFunc) By the way, here is the wiki page that I found - https://developer.roblox.com/api-reference/function/Instance/GetPropertyChangedSignal spearmint123 20 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

maybye do this...

thevaraibleyouwannadetect = 1
doanothervariablelikethis = thevaraibleyouwannadetect
while true do
 thevaraibleyouwannadetect = 2
 if not thevaraibleyouwannadetect == doanothervariablelikethis then
  print("variable change detected!")
  doanothervariablelikethis = thevaraibleyouwannadetect
end
Ad

Answer this question