My Script Functions Are Not Firing

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)

Just a note it is meant to be in the PlayerAdded event for testing.

Place a print here to place a print here to see if the event is firing

1 Like

The event is not firing. I added your print however it does not fire

PlayerAdded event is inside some function?

It’s on its own. The code I submitted is the full code

I’ve had the same issue with the majority of my PlayerAdded events and I really don’t know how to fix it

Is this inside a local script?

No it’s a server script inside a module inside SSS

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

I find the problem, place the script inside server script service
Edit: Sorry, I got confused reading SSS

Did you test in studio or online? Sometimes PlayerAdded will not fire in studio.

Tested in Roblox Studio need to get 30n characters ah

Not the issue… As I have done that already

I added prints to my module script and both are not printing

Try test it online too, check with print SeichoSuru suggested

Alright hold on will do now in game

put this in the top of your script

print("Test-Pre")
API = require(script.Parent)
print("Test-Post")

if you see the “Test-Pre” message, but you don’t see “Test-Post” then your problem is within your module script and you need to look into that

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.

1 Like