1 | local Number = script.Parent.Number |
2 | local Player = game.Players.LocalPlayer:GetFullName() |
3 | local Max = script.Parent.Max.Value |
4 | local PlayerCrops = game.Workspace.CropsInBackpack.Value |
5 |
6 | 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:
1 | script.Number.Value.Changed:Connect( function () |
2 | --stuff here :D |
3 | end ) |
If this doesn't work, let me know!
For if your number is actually a NumberValue object, not a variable:
1 | local Number = script.Parent.Number -- The gui that will change |
2 | local NumberValueThatWillChange = game.Workspace.CropsInBackpack -- Hopfully this is the number that changes |
3 |
4 | NumberValueThatWillChange.Changed:Connect( function (Property) |
5 | if Property = "Value" then -- Make sure that the value is changing, not the name or something |
6 | Number.Text = tostring (NumberValueThatWillChange) -- tostring makes sure of no errors in that area |
7 | end ) |
For if your number is a variable:
01 | local Number = script.Parent.Number -- The gui that will change |
02 | local NumberValueThatWillChange = 69 -- 69, Nice |
03 | local PastNumberValue = NumberValueThatWillChange -- To check for updates |
04 |
05 | while true do |
06 | if PastNumberValue ~ = NumberValueThatWillChange then |
07 | PastNumberValue = NumberValueThatWillChange |
08 | Number.Text = tostring (NumberValueThatWillChange) -- tostring makes sure of no errors in that area |
09 | end |
10 | wait(. 1 ) |
11 | end |