t3h1dy
(Tia)
September 8, 2022, 7:12pm
#1
Hi i am trying to make a script for a overhead GUI but my script is unable to find the Character’s Head.
local groupID = 3433019
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local guiClone = script.OverheadGui:Clone()
guiClone.Parent = Character.Head
local textlabel = guiClone.TextLabel
local useridlabel = guiClone.TextLabel1
local playerank = Player:GetRoleInGroup(groupID)
textlabel.Text = playerank
useridlabel.Text = Player.Name
end)
end)
Here’s my code. I have tried altering it but nothing seems to work.
1 Like
CZXPEK
(czo)
September 8, 2022, 7:13pm
#2
local groupID = 3433019
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local guiClone = script.OverheadGui:Clone()
guiClone.Parent = Character:WaitForChild("Head")
local textlabel = guiClone.TextLabel
local useridlabel = guiClone.TextLabel1
local playerank = Player:GetRoleInGroup(groupID)
textlabel.Text = playerank
useridlabel.Text = Player.Name
end)
end)
t3h1dy
(Tia)
September 8, 2022, 7:16pm
#3
Now it doesnt show the GUI above head at all
mc7oof
(oof)
September 8, 2022, 7:18pm
#4
Define the head as a variable before attempting to parent something to it. I’ve seen weird things happen like that if you don’t.
And use FindFirstChild
or WaitForChild
as noted above by Tia.
t3h1dy
(Tia)
September 8, 2022, 7:19pm
#5
just tried that and it doesnt work either
mc7oof
(oof)
September 8, 2022, 7:21pm
#6
Make a script that defines the head as a variable.
local head = whatever:FindFirstChild("Head") -- since the character has been added you don't have to use wait print(head) -- and see if you are actually getting the head as the variable
1 Like
mc7oof
(oof)
September 8, 2022, 7:23pm
#7
you can also
print(head.Parent)
if you’re not sure what you are capturing with your variable.
t3h1dy
(Tia)
September 8, 2022, 7:42pm
#8
Yes i tried this and it worked thankyou!!