PlayerAdded not firing no matter what

Not a clue why, tried multiple options and none of them seem to work. Its in a folder inside of ServerScriptService

local Players = game:GetService("Players")
local Gamepasses = {}

local EventsAndCallbacks = game:GetService("ReplicatedStorage"):WaitForChild("EventsAndCallbacks")
local PlayerDataEvents = EventsAndCallbacks:WaitForChild("PlayerDataEvents")
local CheckAttributesLoaded = PlayerDataEvents:WaitForChild("CheckAttributesLoaded")

local GlobalData = require(script.Parent:WaitForChild("GlobalData"))
local DataManager = require(script.Parent:WaitForChild("DataManager"))

local MarketPlaceService = game:GetService("MarketplaceService")
local SpiderCatsID = 4056049

function AddGamepasses(Player, Gamepasses)
	
end

function IsInSPIDERCATS(Player)
	if Player:IsInGroup(SpiderCatsID) then
		return true
	else
		return false
	end
end
function GroupRank(Player)
	return Player:GetRoleInGroup(SpiderCatsID)
end
function PlayerRank(Player)
	for _,DevID in pairs(GlobalData.GetDeveloperIDs()) do
		if DevID == Player.UserId then
			return "developer"
		end
	end
	return "norank"
end

local function AddPlayerAttributes(Player)
	Player:SetAttribute("PlayerRank", PlayerRank(Player))
	Player:SetAttribute("JoinedSpiderCatz", IsInSPIDERCATS(Player))
	Player:SetAttribute("GroupRank", GroupRank(Player))
	Player:SetAttribute("CatBucks", 0)
	Player:SetAttribute("Treats", 0)
	Player:SetAttribute("Banned", false)
	Player:SetAttribute("AttributesLoaded", true)
end

Players.PlayerAdded:Connect(AddPlayerAttributes)
for _, player in ipairs(Players:GetPlayers()) do
	AddPlayerAttributes(player)
end
1 Like

I think it’s because you’re connecting the function without providing a “Player” variable, which breaks the PlayerAdded function and errors, stopping the entire script.

Could be because of the :WaitForChild or any scripts that run infinitely before the .PlayerAdded is run.

1 Like

Try:

Players.PlayerAdded:Connect(function(plr)
AddPlayerAttributes(plr)
end)

and remove the for loop at the end cause im pretty sure you’re trying to change the attributes twice.

Tried this and it didn’t work, forgot to mention there are no errors in the output.

I got rid of the WaitForChild and the PlayerAdded event still wont fire.

fixed it, one of my scripts i was requiring got stuck

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.