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

How could I convert this script to only run when the value is changed instead of using a while loop?

3 answers

You can use GetPropertyChangedSignal. Using .Changed can also be applied in this situation, however will fire without a target property–it will fire whenever anything changed, be it Name, or any other property, you’ll always have to hone down on what was modified which can be tedious or cause further issues. With GetPropertyChangedSignal, you can pass which property you wish to listen to, and receive what changed still too!

local WORLD_OFFSET = script.WORLD_OFFSET

WORLD_OFFSET:GetPropertyChangedSignal("Value"):Connect(function(New)
    print(New)
end)
local WORLD_OFFSET = script.WORLD_OFFSET

WORLD_OFFSET.Changed:Connect(function()
	--Code
end

omg you people are over complicating everything. its easy

game.workspace.numvalue.Changed:Conenct(function()
if game.workspace.numvalue.Value == 1 then
print("1")
end)

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