-- This is an example script located in a Part. local something = workspace.IntValue.Value -- I eventually set my intValue form 1 to 2 with another script script.Parent.Touched:Connect(function() print(something) -- This would print 1 end)
Is there any way for script to check if variable changed it's value?
There's an event you can use called "Changed". Here's an example of how it works :
local something = workspace.IntValue something.Changed:Connect(function(value) --The value is the value that changed print(value) end)
The script prints the new value every time the IntValue changes. So yeah. :P
declare the variable inside the function, the variable is not going to automatically update if the the value changes, lets say you declare a variable called pos
local pos = script.Parent.Position
its going to put its position of where its at in that point in time, so if you put it into the function, it'll declare it everytime its stepped on