After scripting 4 year I’m dissapointed I’m having to make a thread of an issue that seems so simple, but I really can’t figure it out… The title is exactly the issue, the event wont fire.
if it’s a local script, it won’t work because the player has already appeared before the script starts (client loaded, then we play client code, not the other way around). So the problem isn’t that your CHaracterAdded isn’t working, but that your PlayerAdded isn’t working
Ok, just did some more testing and it works but not on initial launch I guess?? I have to actually reset my character for it to run, which leads me to believe the character is loading before the event connects. That doesnt make sense though because how is the character loading faster than the script?
I remember having this issue once aswell and it was because of the order I was calling things so I moved the CharacterAdded listener above the other functions. Can you show us the full script?
local Players = game:GetService("Players")
function playerCharacterAdded(player, character)
if not character then
return
end
print(player, character)
-- do stuff
end
function playerAdded(player)
if player.Character then
task.spawn(playerCharacterAdded, player, player.Character)
end
player.CharacterAdded:Connect(function(character)
playerCharacterAdded(player, character)
end)
end
for _, v in Players:GetPlayers() do
task.spawn(playerAdded, v)
end
Players.PlayerAdded:Connect(playerAdded)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player:Player):()
local function CharAdded(char:Model):()
print(player,"character added:",char)
end
player.CharacterAdded:Connect(CharAdded)
if player.Character~=nil then
CharAdded(player.Character::Model)
end
end)
This is the solution. The problem with your original script was that the player who started the server was already added before your PlayerAdded connection was executed by the server.
Yeah, I just realised that you meant your server script by minimumcharsssssssss lol, I’m guessing it didnt work. Looking at other replies, what if you added a task.wait() at the start of the script? to give any unfinished processes time to complete before the event