Instead of looping forever is there a way I could only run this code if script.WORLD_OFFSET.Value changes?
while true do wait() WORLD_OFFSET = script.WORLD_OFFSET.Value --Vector3.new(0, 0, 0) LOCAL_OFFSET = script.LOCAL_OFFSET.Value -- Vector3.new(2, 3, 9.5) end
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)