Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation Sequence without "bugging"?

Asked by
O_3I 0
5 years ago

So I have this script here that makes the dummy play the animation when a part is touched.

local function onTouch(hit)
    local animationId = 3248288444
    if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
        local animation = Instance.new("Animation")
        animation.AnimationId = "https://www.roblox.com/Asset?ID="..animationId
        print("AnimationLoaded")
        local PlayAnimation = game.Workspace.ScareActor.Humanoid:LoadAnimation(animation)
        PlayAnimation:Play()
        print("PlayingAnimation")
    end
end

script.Parent.Touched:Connect(onTouch)

the only thing is the animation starts over from the begining before it is finshed. So for example, if the animation is 3 seconds long, it would play 1 second, then start over before playing the 3 seconds of it. I know it sounds complicated but I need help if you understand. Thank you.

PS. I tried wait() afterPlayAnimation:Play() and it didn't work.

0
Try adding a debounce to the touched part https://developer.roblox.com/en-us/articles/Debounce Robb12 12 — 5y
0
It worked, thanks! O_3I 0 — 5y
0
Your welcome, if you could mark my answer as accepted that would be appreciated. Robb12 12 — 5y

Answer this question