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

after 2 seconds why is my animation not stopping?

Asked by 4 years ago

So I have a tool that when you click with it enabled, it sends the player who uses it, and the player they targets root parts to 2 parts I specified in a model. While they are sent there, a animation is supposed to play, and then after 2 seconds their rootparts get moved back to the map. The animation plays fine, but after 2 seconds it doesnt stop and it continues playing, heres the script:

01local Tool = script.Parent.Parent.Parent.Parent
02 
03script.Parent.OnServerEvent:Connect(function(plr, Mouse)
04    local rng = math.random(2,2)
05    print(rng)
06    if rng == 2 then
07        print("working")
08        local Detect = Instance.new("Part",workspace)
09        Detect.Transparency = 1
10        Detect.Anchored = true
11        Detect.Size = Vector3.new(50,50,50)
12        Detect.CanCollide = true
13        Detect.CFrame = plr.Character.HumanoidRootPart.CFrame
14 
15        Detect.Touched:Connect(function(hit, Player)
View all 43 lines...
0
It could be that you looped the animation while making it. Try checking that Ghost40Z 118 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The point(i hope) is that you creating a new local for animation, so you stop new animation, not your old

just create a local animation out of an if statement, play on touch and the stopp after the 2.5 seconds.

1local animationTrack = player.Character.Humanoid:LoadAnimation(script.Animations.EnemyAnim)
2--your if statement
3animationTrack:Play()
4end
5 
6wait(2.5)
7animationTrack:Stop()
Ad

Answer this question