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

how do i check if a variable has changed?

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




3 comments

0

i dont think there's a direct way but u can fire a different function every time it changes like Var = 1 function()

0

lul i know a slightly better way than a while loop

3 answers

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

With physical values, do this:

local Value = script.Parent
Value.Changed:Connect(function()
	--Thing here
end

You could use a print statement and the GetPropertyChangedSignal event.

3 comments

0

um he meant for variables not instances

0

Well. The guy did say for instance in his post

0

with that 'for instance' he means 'for example'

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