Hello. I basically want to be able to stop this function when the animation is done playing so it doesn’t keep repeating itself. I already know that someone is gonna be like “use a variable,” which would normally be good advice, but in this case I already tried it and it didn’t work. I basically just need like a return or something for this function to get it to stop running without affecting any other part of the script.
Here’s the function I need to stop:
monsterhumroot.Touched:Connect(function(touch)
if touch == playerbeingchased.HumanoidRootPart then
local previouswalkspeed = monsterhum.WalkSpeed
monster:FindFirstChild("Animate").Enabled = false
task.wait()
for i,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
task.wait()
killdance:Play()
task.wait()
playerbeingchased.Humanoid.Health = 0
monsterhum.WalkSpeed = 0
killdance.Ended:Connect(function()
monsterhum.WalkSpeed = previouswalkspeed
--I want the stop to be here. If it would just stop the .ended function, I can use a
--variable to tell when it ends and do it
end)
--here instead.
end
end)
Thanks!