Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

This error when the script is destroyed:Player:Move called, but player currently has no humanoid?

Asked by 3 years ago

This is my script: wait() local Humanoid = script.Parent.Humanoid Humanoid.BreakJointsOnDeath = false local DA = Instance.new("Animation") DA.AnimationId = "rbxassetid://6101308551" local DeathAnimation = Humanoid:LoadAnimation(DA)

Humanoid.HealthChanged:Connect(function(Health) if Health <= 0 then print("died") script.Parent.HumanoidRootPart.Anchored = true DeathAnimation:Play() wait(2) script.Parent:Destroy()

end

end)

3 answers

Log in to vote
0
Answered by 3 years ago

This is because the humanoid is not currently loaded in. You have to wait for it, like this:

local Humanoid = script.Parent:WaitForChild("Humanoid")
0
Where do I add that? kodakpro87 7 — 3y
Ad
Log in to vote
0
Answered by 2 years ago

i figured out when this happens, DON'T call :Destroy() on player, use :Remove() instead.

Log in to vote
0
Answered by 1 year ago

I had the same problem and I just did this. This script deletes everything except the humanoid. Here is the script:

for _,v in pairs(char:GetChildren()) do if v.ClassName == "Humanoid" then wait() else v:Destroy() end end

Answer this question