Hey gamers! I’m attempting to parent a BillboardGui into a Character’s Head. For some reason I’ve had this in my game where the PlayerAdded and the CharacterAdded events do not fire. Here is my code I’m attempting to run.
local API = require(script.Parent)
local findBoard = API:GetBoardID("Nametags")
local findlist = API:GetListID("Players",findBoard)
local cards_in_list = API:GetCardsInList(findlist)
game.Players.PlayerAdded:Connect(function(plr)
for a,b in pairs(API:GetCardsInList(findlist)) do
local split = string.split(b.name, ":");
local name = tostring(split[1]);
local id = tonumber(split[2]);
if id == plr.UserId then
local rank = game.ServerStorage.RankGui:Clone()
rank.Name2.Text = b.desc
rank.Rank.Value = "Uhoh"
rank.Parent = plr.Character.Head
else
local rank = game.ServerStorage.RankGui:Clone()
rank.Parent = plr.Character.Head
rank.Name2.Text = plr.Name
print(rank.Name2.Text)
rank.Rank.Value = "Uhoh"
print(rank.Rank.Value)
print(rank.Parent.Name)
end
end
plr.CharacterAdded:Connect(function()
end)
end)
Put a print before and after your API variable reference, if you’re not seeing the second print then there could be a delay in your module that you’re requiring
It’s likely because your Player/Character is loaded before you script is able to listen for the event. What you should do is use functions, and call them relative to each other. Something like:
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local function onCharacterAdded(character)
print(player.Name .. " loaded in: " .. character.Name)
-- do stuff
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
But maybe that’s is not the issue.
Also, this often happens where you’re testing solo in Studio.