Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

If leaderstats is this high, then change sign text?

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!

local Player = game.Players.LocalPlayer
	local Stats = Player:WaitForChild("leaderstats")
	local Money = Stats:WaitForChild("Johanna")
	 wait(1)
	if Money < 49 then script.Parent.SurfaceGui.SIGN.Text = "Hello!"
	else
			if Money > 49 then script.Parent.SurfaceGui.SIGN.Text = "Not enough money."
	end

2 comments

0

I think this is because you need to be accessing the Value property of the Money leaderstat.

0

What do you mean?

2 answers

✓ Accepted answer

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

local Player = game.Players.LocalPlayer
local Stats = Player:WaitForChild("leaderstats")
local Money = Stats:WaitForChild("Johanna")
wait(1)
Money: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.
	if Money.Value > 49 then
		script.Parent.Parent.SurfaceGui.SIGN.Text = "Not enough money."
	else
		script.Parent.Parent.SurfaceGui.SIGN.Text = "Hello!"	
	end
end)

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

10 comments

0

Thank you for responding! But sadly, this didn't work. The text didn't change.

0

hmmmm, interesting, any errors?

0

No, which is strange.

0

are you changing the value of the money?

0

No

0

Then you change the value of the money and the event will fire.

0

How do you change the value?

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.

0

Thank you!

0

np!

This discussion is preserved as it was. New answers, comments, and votes are closed.