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

How can you detect if a variable has changed?

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.

1 comment

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

1 answer

maybye do this...

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

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