Hello!
Player.Name isn’t working (I am using a normal script so I think that is it.) How do I solve this?
Hello!
Player.Name isn’t working (I am using a normal script so I think that is it.) How do I solve this?
It’d help if you could provide the script
player.CharacterAdded:Connect(function(character)
local rankclone = script.OverheadGui:Clone()
rankclone.Parent = player.Character.Head
local ranktext = rankclone.Rank
ranktext.Text = player:GetRoleInGroup(11397447)
local nametext = rankclone.Name
nametext.Text = player.Name
end)
end)
The last line before end is the trouble.
May I ask where you put the script exactly? And are there any errors on the Output at all?
ik this doesn’t help but what is the point of this if the character is already defined
character.Head
No error in output, ServerScriptService.
I’d just recommend checking for print statements, the script should work fine so you should debug it for further inspection & see where the issue may lie closer
player.CharacterAdded:Connect(function(character)
print("This works")
local rankclone = script.OverheadGui:Clone()
rankclone.Parent = character.Head
print("This works as well")
local ranktext = rankclone.Rank
ranktext.Text = player:GetRoleInGroup(11397447)
local nametext = rankclone.Name
nametext.Text = character.Name
print("Current Text: "..nametext.Text)
print("This should work")
end)
Didn’t work starting right here.
Are you sure you’re indexing the children of the OverheadGui
object correctly? And you’re sure there’s no errors?
Only other thing I can think of is making a reproduction file, cause that shouldn’t happen
Hi there! How do you define Player
in your script?
game.Players.PlayerAdded:Connect(function(player)
I found the error. The error is coming from the local nametext = rankclone.Name
line. To fix your issue, just change this line to local nametext = rankclone["Name"]
. Your current script returns the name of your instance called “rankclone”.
I know the issue as I’ve experienced this tons of times,
player.CharacterAdded:Connect(function(character)
print("This works")
local rankclone = script.OverheadGui:Clone()
rankclone.Parent = character.Head
print("This works as well")
local ranktext = rankclone.Rank
ranktext.Text = player:GetRoleInGroup(11397447)
local nametext = rankclone.Name -- The culprit line
nametext.Text = character.Name
print("Current Text: "..nametext.Text)
print("This should work")
end)
Reason why this line errors out you have it Referencing the “rankclone” Name not an object, A way you can fix this is by changing stuff to :FindFirstChild() instead or simply changing the name to something that isn’t a roblox Property.
Your getting the Name property, rename your name object to something else like “PlayerName” or use FindFirstChild
Renaming isn’t needed. Instead they can just use Instance["Name"]
.
That wouldn’t work either, I’ve made a few scripts that uses that method for cloning properties to another item.
thats why I suggested either renaming it or using :FindFirstChild or :WaitForChild()
warn(game.Workspace.Part["Name"].Color)``` -- Expected output | New Yeller
warn(game.Workspace.Part["Name"].Color)``` -- Actual output | nil