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

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

Asked by 8 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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

0
Where's the script buddy? GreekGodOfMLG 244 — 8y

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
8 years ago

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.

Ad

Answer this question