I have a tool with a local script inside. The local script finds the character humanoid and loads animations into it.
When first spawning it works just fine, but when respawning it quits working. It seems to index the humanoid of the first character rather than the new, second one.
--Localscript inside of the tool. Original tool is in StarterPack.
--Code is simplified.
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local function LoadAnimation(Anim)
local Success, Returned
print("Loading Animation '" .. Animation.AnimationId .."'...")
while not Success do
Success, Returned = pcall(function()
-- I need to check this cos or else the AnimationClipProviderService error occurs.
if not Humanoid:IsDescendantOf(workspace) then
error("Humanoid isn't in workspace.")
end
return Humanoid:LoadAnimation(Animation)
end)
if not Success then
print("Fail:", Returned)
task.wait(1)
else
print("Success.")
end
end
return Returned
end
LoadAnimation(script:WaitForChild("MyAnim"))
Here is the output:
(Character Spawns)
Loading Animation ‘[anim id here]’
Success.
(Character dies, then respawns)
Loading Animation ‘[anim id here]’
Fail: Humanoid isn’t in workspace. (repeats forever)
If you need more info, just ask.