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

NPC's Animation Not loading ( My script Is wrong? )

I tried to make an assassin NPC, That follow's ( worked ), And also do damage on the player with debounce cooldown ( worked ), So here's the Attack Script

local rarm = script.Parent.LeftLowerArm
local larm = script.Parent.RightLowerArm
local Hum = script.Parent.HumanoidRootPart
local debounce = false
function attack(dmg)
	if not debounce then
		debounce = true
	
	if dmg.Parent:FindFirstChild("Humanoid") then
		script.Parent.Humanoid:LoadAnimation(script.Parent.Animations.SpiningBladeAnimation)
		dmg.Parent.Humanoid.Health = dmg.Parent.Humanoid.Health -10
		wait(4)
		debounce = false
		end
		end
	end
	

rarm.Touched:Connect(attack)
larm.Touched:Connect(attack)
Hum.Touched:Connect(attack)

So when the NPC Touches me ( Because of the Following Script ) And i take damage, It Doesn't Load the animation I checked the OutPut and there's nothing. Can you help me out?

1 answer

✓ Accepted answer

Although you have loaded the animation, you have not told the script to play it.

Here is an example on how it should go:

local Animation = Instance.new('Animation')
Animation.AnimationId = 'rbxassetid://0' -- change this to the asset ID of your animation
local Track = Character.Humanoid:LoadAnimation(Animation) -- load it into the humanoid
Track:Play() -- Always need to tell the track to play.

You can learn more about Animations here: https://developer.roblox.com/en-us/api-reference/class/Animation

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