after 2 seconds why is my animation not stopping?
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:
01 | local Tool = script.Parent.Parent.Parent.Parent |
03 | script.Parent.OnServerEvent:Connect( function (plr, Mouse) |
04 | local rng = math.random( 2 , 2 ) |
08 | local Detect = Instance.new( "Part" ,workspace) |
09 | Detect.Transparency = 1 |
10 | Detect.Anchored = true |
11 | Detect.Size = Vector 3. new( 50 , 50 , 50 ) |
12 | Detect.CanCollide = true |
13 | Detect.CFrame = plr.Character.HumanoidRootPart.CFrame |
15 | Detect.Touched:Connect( function (hit, Player) |
18 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
21 | local AttackPart = game.Workspace.TsukuyomiModel.AttackerPart |
22 | local EnemyPart = game.Workspace.TsukuyomiModel.EnemyTsukuPart |
23 | plr.Character:WaitForChild( "HumanoidRootPart" ).CFrame = AttackPart.CFrame |
24 | player.Character:WaitForChild( "HumanoidRootPart" ).CFrame = EnemyPart.CFrame |
25 | player.Character.HumanoidRootPart.Anchored = true |
26 | player.Character.UpperTorso.CFrame = CFrame.new(- 67.91 , - 224.94 , 202.345 ) * CFrame.fromEulerAnglesXYZ( 0 , 89.5 , 0 ) |
27 | local animationTrack = player.Character.Humanoid:LoadAnimation(script.Animations.EnemyAnim) |
29 | player.Character.Humanoid:TakeDamage( 1 ) |
34 | local returnpart = game.Workspace.returnpart |
36 | player.Character.HumanoidRootPart.Anchored = false |
37 | plr.Character:WaitForChild( "HumanoidRootPart" ).CFrame = returnpart.CFrame |
38 | player.Character:WaitForChild( "HumanoidRootPart" ).CFrame = returnpart.CFrame |
39 | local animationTrack = player.Character.Humanoid:LoadAnimation(script.Animations.EnemyAnim) |