I have a rank system and need to add a BillboardGui to the character of every player who joins the game. The BillboardGui goes inside their character model, inside “Head.” I tried doing this process inside the PlayerAdded event, but the character may not be loaded when this event fires. The CharacterAdded event fires when the player is assigned a character, meaning it fires before the character model is added to the workspace. There are other things such as CharacterAppearanceLoaded and HasAppearanceLoaded, but if a Roblox server issue is present and the player’s avatar isn’t fully loading, this will error the entire script (server script btw).
Does anyone know how I can ensure the character model is present in the workspace without causing any errors or using while loops?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local character = player.Character
if character then
if game.Workspace:FindFirstChild(player.Character.Name) then
-- insert code here
end
end
end)
If the billboard is meant to go in the head each time, you’ll want to attach an event for when a character is added like this:
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local head = character:WaitForChild('Head')
-- Do stuff
end)
end)
Alternatively, you can just put a script inside of StarterCharacterScripts, and then the parent of that script will be the player’s character.