I need your help to create a text label that shows all player values,i know this is seems easy,but the problem is My game has a ‘rebirth system’,where if you rebirth all your value resets,and yeah of course if value resets text resets too.
If you don’t understand what I mean, let me explain it again in more detail.
For example, I have 100 cash and of course the text is 100 too (because I used this script,The number of text is based on the number of clicks):
While Wait() do
script.Parent.Text = player.Stats.Cash.Value
end
And if I want to do a rebirth of course my cash will be 0, and the text will be 0 too.
So is there a way to make the text based on all the cash that has been collected from the player?
You can use this simple code to link the text with the value of money:
-- locals
local player = game.Players.LocalPlayer
-- when player join the game the value will be added automatically
script.Parent.Text = player.Stats.Cash.Value
-- will change the text automatically with the value
player.Stats.Cash:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Text = player.Stats.Cash.Value
end)
Most likely not. You wont need to redo your script too. Just create a value, setup a datastore for it and whenever you add cash, just drop a line and add also the same amount to that value
Yes I know that, but in my game it doesn’t just have 2,3,5 scripts(line) i add cash,there like 50+ scripts(line) and yeah I’ll probably get confused if I have to search them all with ctrl + f.
Maybe do you know how to detect if value change to smaller or bigger?
Yes you can also detect a value beeing changed by doing GetPropertyChangedSignal. Also note that at the top is a menu named Script Menu. There you can do Find > Find All to search in all scripts
make a new IntValue when player join your game with this properties
Name = “oldValue”
Value = player.Stats.Cash.Value
Parent = player
and new value = player.Stats.Cash.Value
so you should edit the code of +50 cash to :
player.oldValue = player.Stats.Cash.Value
wait(0.05)
player.Stats.Cash.Value = player.Stats.Cash.Value + 50
local x
if player.oldValue > player.Stats.Cash.Value then
x = "-"
elseif player.oldValue < player.Stats.Cash.Value then
x = "+"
end