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

Make this GUI show the val of a val in players?

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

1 comment

0

Where's the script buddy?

1 answer

✓ Accepted answer

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.

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