Animations won't work after character reseting

  1. What do you want to achieve? Keep it simple and clear!

Simple as it is, just run the animation.

  1. What is the issue? Include screenshots / videos if possible!
    Every time the user resets the animation won’t work with the error:
    PpYADp31

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Unluckily, I haven’t found any solutions, not even in the dev hub.

The code is:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:WaitForChild("Humanoid")
local anim = script:WaitForChild("Animation")
local tool = script.Parent
local remote = game:GetService("ReplicatedStorage"):WaitForChild("Breaths"):WaitForChild("Moon"):WaitForChild("Ringtail")
local loadAnimation = humanoid:LoadAnimation(anim)


tool.Activated:Connect(function()
	local cooldown = script.Parent.Cooldown
	if cooldown.Value == 0 then
		local data = char:WaitForChild("HumanoidRootPart").CFrame
		remote:FireServer(data)
		print(tostring(data))
		cooldown.Value = 100
	loadAnimation:Play()
	humanoid.WalkSpeed = 0
	wait(1.6)
		humanoid.WalkSpeed = 16
		wait(5)
		cooldown.Value = 0
	else
		print("no lol")
		end
end)

  • Script is located under a tool.
    Overall, I just wanna fix the Animation error but sending the whole script may help me more.

dont mind my bad scripting

I managed to fix it myself.

-- Old variable
local char = plr.Character or plr.CharacterAdded:Wait()
-- New:
local char = plr.CharacterAdded:Wait()

yeah that works, usually it’s a good practice to force scripts to wait for all instances related to the tool before it starts running since only events are constantly running, the lines of codes running on their own will start even if there’s no character or humanoid.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.