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
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
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!
Replace "StarterGui" with "PlayerGui", when dealing with LocalPlayers you don't access them via "StarterGui" but with "PlayerGui".
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Have your tried putting the script in StarterPlayerScripts?