local Number = script.Parent.Number local Player = game.Players.LocalPlayer:GetFullName() local Max = script.Parent.Max.Value local PlayerCrops = game.Workspace.CropsInBackpack.Value Number.Text = (PlayerCrops.. " / ".. Max)
So, I want to check if a number value got updated. How would I do that? For example, If say a number value of 1 got updated to like a value of 3. How would I check for that? So I can update my Gui everytime the value gets changed.
Hi there! What you could do is store an IntValue in a script, and then write something like this in another script, if I am correct:
script.Number.Value.Changed:Connect(function() --stuff here :D end)
If this doesn't work, let me know!
For if your number is actually a NumberValue object, not a variable:
local Number = script.Parent.Number -- The gui that will change local NumberValueThatWillChange = game.Workspace.CropsInBackpack -- Hopfully this is the number that changes NumberValueThatWillChange.Changed:Connect(function(Property) if Property = "Value" then -- Make sure that the value is changing, not the name or something Number.Text = tostring(NumberValueThatWillChange) -- tostring makes sure of no errors in that area end)
For if your number is a variable:
local Number = script.Parent.Number -- The gui that will change local NumberValueThatWillChange = 69 -- 69, Nice local PastNumberValue = NumberValueThatWillChange -- To check for updates while true do if PastNumberValue ~= NumberValueThatWillChange then PastNumberValue = NumberValueThatWillChange Number.Text = tostring(NumberValueThatWillChange) -- tostring makes sure of no errors in that area end wait(.1) end