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

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

Asked by 5 years ago
Edited 5 years ago

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)

0
player.Team is an instance, not a string, change it to player.Team.Name User#20388 0 — 5y
0
Thank you! MaxDev_BE 55 — 5y
0
np User#20388 0 — 5y

1 answer

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

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.

0
Why is this not working to? workspace:FindFirstChild(player.Name).Head.Rank.Frame.Name.Text = player.Name MaxDev_BE 55 — 5y
0
I edited my answer, might work now. radusavin366 617 — 5y
0
But i want that the Name changes to the player's name see i updated my question to MaxDev_BE 55 — 5y
0
Any output? radusavin366 617 — 5y
View all comments (5 more)
0
Error is updated to MaxDev_BE 55 — 5y
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? radusavin366 617 — 5y
0
Look now that what i did but still niot working? MaxDev_BE 55 — 5y
0
.....output??? radusavin366 617 — 5y
0
Still same MaxDev_BE 55 — 5y
Ad

Answer this question