I am making an overhead gui with the name of the user and his rank
Everything works fine but when the player dies or refresh the gui is gone
i tried to add if statements like that
if not char.Head:FindFirstChild"Rank" then -- rank is a billboard gui
giveoverhead(plr) -- function that removes any bill boards in the head
-- and clone them from the replicated storage
end
if not char.Head:FindFirstChild"Username" then -- username is a billboard gui
giveoverhead(plr)
end
and i tried to add remotes events but it didnt work
game.Players.PlayerAdded:Connect(function(player)
local function giveoverhead(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local rep = game:GetService("ReplicatedStorage")
local rank_clone = rep.Rank:Clone()
local user_clone = rep.Username:Clone()
rank_clone.Parent = char:WaitForChild("Head")
user_clone.Parent = char:WaitForChild("Head")
rank_clone.Adornee = char:WaitForChild("Head")
user_clone.Adornee= char:WaitForChild("Head")
rank_clone.TextLabel.Text = plr:GetRoleInGroup(6089525)
user_clone.TextLabel.Text = plr.Name
end
You need to call the function whenever a character is added, not when the player is.
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
--<Check for the head within here
giveoverhead(plr)
end)
end)
The easiest way to do this is to drop a script inside of StarterCharacterScripts.
This folder will have all of its contents cloned to the player’s character every time it gets added into the game.
Since it adds the script into the player’s character, you can define char as script.Parent.
Remember that this also means you can add both server scripts and local scripts to the folder and they will both run regardless.