Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

May I have help as to why my animation script is not working?

How my script works is that when the tool is activated it plays an animation, it is for a sword.

I am terrible with animations lol so heres the script!

local tool = script.Parent

local Damage = script.Parent:WaitForChild("DamageAmount").Value

tool.Activated:Connect(function()

local anim = script.Parent:WaitForChild("Slice")

local char = script.Parent.Parent

local animTrack = char.Humanoid.Animator:LoadAnimation(anim)

animTrack:Play()

tool:WaitForChild("Sword").Touched:Connect(function(hit)
	local player = script.Parent.Parent.Name
	local touched = hit.Parent
	
	if touched.Name ~= player then
		if touched:FindFirstChild("Humanoid") then
			touched.Humanoid.Health = touched.Humanoid.Health - Damage
		end
	end
	
end)

end)

1 answer

When Loading your animation, you only need to access the humanoid you're playing the animation on.

local animTrack = char.Humanoid.Animator:LoadAnimation(anim)

Should really just be

local animTrack = char.Humanoid:LoadAnimation(anim)

if this doesn't work i apologize, but this should fix ur issue.

1 comment

0

It does not work. I have already done this before and it didnt work because somebody told me it was deprecated.

This discussion is preserved as it was. New answers, comments, and votes are closed.