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

My GUI script will only work in Studio and not in the Player, How can I fix this?

Asked by 7 years ago

I've made a script that displays the player's name above a local gui but it only works in studio. I've tried this

playerName = game.Players.LocalPlayer.Name
game.StarterGui.HPGUI.Frame.Player.playerName.Text = playerName
0
Have your tried putting the script in StarterPlayerScripts? JoeRaptor 72 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

The solution is very simple. You see, you're editing the StarterGui. The changes work in studio, but not in a game.

To fix this, just change StarterGui to PlayerGUI and a few other things

Final script:

player = game.Players.LocalPlayer -- Incase you need it for other needs, plus you can get the name in the line you call it.

player.PlayerGui.HPGUI.Frame.Player.playerName.Text = player.Name --Switched it to PlayerGUI, and changing playername to player.Name

Questions? Concerns? Make sure to ask!

Ad
Log in to vote
0
Answered by 7 years ago

Replace "StarterGui" with "PlayerGui", when dealing with LocalPlayers you don't access them via "StarterGui" but with "PlayerGui".

Answer this question