It worked before I had a val inside players, but now that there is, the players do not get their val shown in the gui
Well, to do this, you first need to find the value inside the player by using WaitForChild
. This will return false until "Money" is found. This is so it doesn't return a error if "Money" hasn't loaded yet. Also, you can access the player by using game.Players.LocalPlayer
in a localscript.
local player = game.Players.LocalPlayer local money = player:WaitForChild("Money") --you do not have to check for "Money" in their money because on your value script, you add "Money" to the player.
Now that we have our variables set up, it's actually time to change the text. We need a infinite loop to update the money, and using script.Parent.Text
to actually change the text.
while wait(1) do --updates the text every 1 second script.Parent.Text = "Money: " .. money.Value --changes the text to show their money end
Finally, with everything added together you will have this as your code.
local player = game.Players.LocalPlayer local money = player:WaitForChild("Money") while wait(1) do --updates the text every 1 second script.Parent.Text = "Money: " .. money.Value --changes the text to show their money end
If this worked or helped, make sure to thumbs up and accept this as your answer. Also, if you're having trouble with where to put things, add a localscript in the button you want it to show text on.