Hi, I'm trying to get the LocalPlayer's name for various things, and as a test I wanted to just print the value of their name. However, with the code I've got, nothing is happening when I run the game.
--ignore the stuff that's commented out below kthxbye
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
--local baseClaim = game:GetService("ReplicatedStorage").baseClaim
function onPlayerAdded()
local playerName = localPlayer.Name
print(playerName)
--baseClaim:FireServer()
end
Players.PlayerAdded:Connect(onPlayerAdded)
That's the code, it's within a LocalScript that is placed in a normal ScreenGui within StarterGui.
I'm getting no errors or anything from this script, it's just not printing anything.
Thanks for any help.

3 comments
It works by itself in a LocalScript but if I add it to the Script I posted above, it still doesn't work?
For reference, I added the first two lines of your script (the ones that define the String) to before the onPlayerAdded() function in mine. I added the print(string.value) to mine where it says print(PlayerName), i replaced it
It could be that you're not loaded yet, and the game executes your code before-hand. As there is no way for it to prioritise events except for yourself. E.g. Using a yield command, using RepFirst etc...