Oh, I see the issue. It seems more like you’re running into a timing issue which again is still a product of faulty avatar loading events ordering. Please bother Roblox to get it in already.
I added a bit of extra code in the sample and tried running it. As I had suspected, comparing the data I attached to the character for the first time and checking it on respawn showed that the old character is still being referenced by the LocalScript.
local CollectionService = game:GetService("CollectionService")
local HttpService = game:GetService("HttpService")
local p = game.Players.LocalPlayer
local c = p.Character
if not c then
c = p.Character
while c.Parent == nil do
--print("Char added to " .. c.Parent.Name)
local h = c:WaitForChild("Humanoid")
--local an = h:LoadAnimation(script.Anim)
Replace your code with this and check what GUID is printed to the console. You’ll notice that you get one when you first spawn and then when the while loop is running, it prints that same initial GUID out to the console from the old character.
Simply refreshing the variable provided me with a degree of success in resolving this, although there was still one iteration (frame) where the character is registered as the old one. In the while loop, above or below the wait, add in
c = p.Character and it’ll stop infinitely printing nils.