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

This script wont work?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
game.Players.PlayerAdded:connect(function(plr)
    if plr then
        plr.PlayerGui.Cash.TextLabel.Text = "100$"
    end
end)

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

The problem here is that the items inside of plr have not loaded yet because the player was just created. Use WaitForChild to wait for them to load:

game.Players.PlayerAdded:connect(function(plr)
    plr:WaitForChild("PlayerGui"):WaitForChild("Cash"):WaitForChild("TextLabel").Text="$100"
end)
0
Does not work duckyo011 36 — 8y
0
It won't work offline because players are created before scripts run. It does work online. 1waffle1 2908 — 8y
0
There should really be an entire article devoted to why people should be using client and server tests over the Play Solo feature. I've seen so many issues arise from people giving Play Solo merit. It's about as powerful as the command bar, except with a termination option. Legojoker 345 — 8y
Ad

Answer this question