Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does anyone what i do bad? What does the error mean? attempt to index field 'Name' ...

This is a serverscript in ServerScriptService? Can anyone help me?

game.Players.PlayerAdded:Connect(function(player)
	workspace.ChildAdded:Connect(function(child)
		local plr = game.Players:FindFirstChild(child.Name)
		if child.Name == plr.Name then
			wait()
			local clone = script.Rank:Clone()
			clone.Parent = workspace:FindFirstChild(plr.Name).Head
			local rank = workspace:FindFirstChild(plr.Name.Head.Rank.Frame)
			rank.Team.Text = plr.Team.Name
			rank.Team.TextStrokeColor3 = plr.TeamColor.Color
			rank.Name.Text = plr.Name
		end
	end)
end)

error is : attempt to index field 'Name' (a string value)

3 comments

0

player.Team is an instance, not a string, change it to player.Team.Name

0

Thank you!

0

np

1 answer

✓ Accepted answer

You're trying to set the textlabel's text to an instance and not the instance's name.

To fix this do:

local playertoset = workspace:FindFirstChild(player.Name)
playertoset.Head.Rank.Frame.Team.Text = player.Team.Name 

on line 6.

9 comments

0

Why is this not working to? workspace:FindFirstChild(player.Name).Head.Rank.Frame.Name.Text = player.Name

0

I edited my answer, might work now.

0

But i want that the Name changes to the player's name see i updated my question to

0

Any output?

0

Error is updated to

0

On line 7, it might be because it thinks that by "Frame.Name" youre reffering to the frame's name, not the textlabel. Rename the textlabel to something more suggestive, like plName and edit your script accordingly?

0

Look now that what i did but still niot working?

0

.....output???

0

Still same

This discussion is preserved as it was. New answers, comments, and votes are closed.