Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If leaderstats is this high, then change sign text?

Asked by 5 years ago

So I am making a game, and I want it where if you have more than 49 dollars, the sign will say something if you have less than 49 dollars, it says something different. I made random words for this example, so here it is. The problem is that the sign doesn't change. Thank you!

1local Player = game.Players.LocalPlayer
2    local Stats = Player:WaitForChild("leaderstats")
3    local Money = Stats:WaitForChild("Johanna")
4     wait(1)
5    if Money < 49 then script.Parent.SurfaceGui.SIGN.Text = "Hello!"
6    else
7            if Money > 49 then script.Parent.SurfaceGui.SIGN.Text = "Not enough money."
8    end
0
I think this is because you need to be accessing the Value property of the Money leaderstat. 123marble 61 — 5y
0
What do you mean? PadmeOragana 78 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

What I believe you need is to detect is the player's money value has change. For that, I will be using GetPropertyChangedSignal

01local Player = game.Players.LocalPlayer
02local Stats = Player:WaitForChild("leaderstats")
03local Money = Stats:WaitForChild("Johanna")
04wait(1)
05Money:GetPropertyChangedSignal("Value"):Connect(function() -- Using GetPropertyChangedSignal instead of .Changed to only detect the money value changing since .Changed will always fire when the money's properties has been changed such as it's name.
06    if Money.Value > 49 then
07        script.Parent.Parent.SurfaceGui.SIGN.Text = "Not enough money."
08    else
09        script.Parent.Parent.SurfaceGui.SIGN.Text = "Hello!"   
10    end
11end)

Hope this helps, and remember to accept it if it did! Any errors, report to me and I will fix it asap!

0
Thank you for responding! But sadly, this didn't work. The text didn't change. PadmeOragana 78 — 5y
0
hmmmm, interesting, any errors? XviperIink 428 — 5y
0
No, which is strange. PadmeOragana 78 — 5y
0
are you changing the value of the money? XviperIink 428 — 5y
View all comments (6 more)
0
No PadmeOragana 78 — 5y
0
Then you change the value of the money and the event will fire. XviperIink 428 — 5y
0
How do you change the value? PadmeOragana 78 — 5y
0
Im assuming you a have server script to create the leaderstats when the player has joined, just use a loop to changed to the value every x seconds. XviperIink 428 — 5y
0
Thank you! PadmeOragana 78 — 5y
0
np! XviperIink 428 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Thank you everybody for responding!

Answer this question