so i am creating an npc that attacks you when close but you can kill him by pressing the button
on his back!
so when you press the button the walk animation should stop and get replaced by the stun animation (while changing the eye color to green and after the button is pressed 3 times he dies) this part (in brackets) works btw it’s just the animation so don’t look at the brickcolor.new-stuff.
local Stun = script:WaitForChild("Animation")
local Host = script.Parent.Parent:WaitForChild("Humanoid")
local StunAnim = Host:LoadAnimation(Stun)
local walk = script:WaitForChild("walk")
local walkanim = Host:LoadAnimation(walk)
walkanim:Play()
script.Parent.Touched:Connect(function()
walkanim:Stop()
local DeathOnTouch = 0
script.Parent.CanTouch = false
script.Parent.Parent.righteye.BrickColor = BrickColor.new(0,1,0)
script.Parent.Parent.lefteye.BrickColor = BrickColor.new(0,1,0)
script.Parent.Parent.charge.Disabled = true--charge is the pathfinding
StunAnim:Play()
wait(10)
StunAnim:Stop()
script.Parent.Parent.righteye.BrickColor = BrickColor.new(1,0,0)
script.Parent.Parent.lefteye.BrickColor = BrickColor.new(1,0,0)
script.Parent.Parent.charge.Disabled = false
DeathOnTouch = DeathOnTouch +1
if DeathOnTouch == 3 then
--Sound:Play()
workspace.DumBot1000:Destroy()--dumbot is the name
end
can someone tell me the problem?