-
What do you want to achieve? Just want the character added event to work on the script.
-
What is the issue? The problem is that when the player dies and when they respawn the character added event never gets fired. For example when they choose a team the function gets fired.
-
What solutions have you tried so far? I don’t know why the character added event never fires, it used to work but not anymore. I also changed the code some bit and I haven’t fixed the problem.
I just want the character added not firing problem to get fix. Look at the code below I added a comment of where the problem is.
local function CriminalCharacterAdded(character)
-- Run code here [Don't want to leak the code], There's no problems here
end
criminalTeam.PlayerAdded:Connect(function(player)
-- This works as expected and waits for the character
local character = player.Character or player.CharacterAdded:Wait()
-- Calls the function as it's suppose to
CriminalCharacterAdded(character)
-- This is the part that never fires the CriminalCharacterAdded Function when the character is added
connections[player.Name] = player.CharacterAdded:Connect(function(playerCharacter)
CriminalCharacterAdded(playerCharacter)
end)
end)
criminalTeam.PlayerRemoved:Connect(function(player)
-- This also works as expected
if connections[player.Name] ~= nil then
connections[player.Name]:Disconnect()
end
end)