Hey there! So in the following days, I’ve been developing and scripting a game, however I won’t be mentioning about it in here, I will only be saying what the problem, script, explorer.
My problem:
I’m scripting something, I tried debugging however it does not work even I’m debugging it correctly. It’s a Head Tag, most likely easy to solve but it doesn’t end up easy to me as I’m still learning.
The Script:
local groupID = 10329333 -- GROUP ID
game.Players.PlayerAdded:Connect(function(player) -- Connect Player
local groupRank = player:GetRoleInGroup(groupID) -- Group Rank
local clone = game.ReplicatedStorage.RankTag:Clone() -- Rank Tag
local clone2 = game.ReplicatedStorage.UserTag:Clone() -- UserTag
clone2.TextLabel.Text = player.Name -- User Tag Text
clone.TextLabel.Text = groupRank -- Rank Tag Text
player.CharacterAdded:Connect(function(char) -- Connect Character
clone.Parent = game.Workspace:WaitForChild(player.Name).Head -- Rank Tag Parent
local groupRank = player:GetRoleInGroup(groupID) -- Get Rank
clone2.Parent = char.Head -- User Tag Parent
end)
end)
The Explorer:
Any help is appreciated, thank you for reading this.
Alright, I assume the problem is because the head hasn’t loaded in the character at the point you try to parent it. Do something like this:
local groupID = 10329333 -- GROUP ID
game.Players.PlayerAdded:Connect(function(player) -- Connect Player
local groupRank = player:GetRoleInGroup(groupID) -- Group Rank
--I moved the clones so I towuld cone it everytime they respawn instead of only once.
player.CharacterAdded:Connect(function(char) -- Connect Character
repeat
wait()
until char.Head
local clone = game.ReplicatedStorage.RankTag:Clone() -- Rank Tag
local clone2 = game.ReplicatedStorage.UserTag:Clone() -- UserTag
clone2.TextLabel.Text = player.Name -- User Tag Text
clone.TextLabel.Text = groupRank -- Rank Tag Text
clone.Parent = char.Head -- Rank Tag Parent
clone2.Parent = char.Head -- User Tag Parent
end)
end)
I also fixed some other problems with the script for you.