I’m having trouble with the enemies in my game. They chase and attack me just fine except for when they kill me and i respawn. After i respawn they completely ignore me and don’t bother chasing or attacking me. What are some ways to detect when a player respawns?
I’ve already tried listening for the CharcterAdded event on each player.
I’ve also tried to update the enemy’s targeting logic to use the latest character instance.
Nothing works. I would post the script but its about 400 lines long since it contains pretty much all the behavior of the NPC’s
heres the part of the code that handles player respawning. Everything looks fine to me but i could be missing something or messed something up
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
print("Player respawned:", player.Name)
wait(0.1) -- Wait for character to fully load
chasePlayer(player) -- Resume chase for respawned player
end)
end)
How exactly are you checking which players to attack?
If you are only checking for the players currently alive in a certain minigame, it might be an issue on how you are adding the player to that array.
If you are checking through the current existing players to get the closest of them all, try using Players:GetPlayers(), you can refresh through your targetting logic to eaither get the same, or different result.