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:
local Tool = script.Parent.Parent.Parent.Parent
script.Parent.OnServerEvent:Connect(function(plr, Mouse)
local rng = math.random(2,2)
print(rng)
if rng == 2 then
print("working")
local Detect = Instance.new("Part",workspace)
Detect.Transparency = 1
Detect.Anchored = true
Detect.Size = Vector3.new(50,50,50)
Detect.CanCollide = true
Detect.CFrame = plr.Character.HumanoidRootPart.CFrame
Detect.Touched:Connect(function(hit, Player)
print("test")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
print("testing")
local AttackPart = game.Workspace.TsukuyomiModel.AttackerPart
local EnemyPart = game.Workspace.TsukuyomiModel.EnemyTsukuPart
plr.Character:WaitForChild("HumanoidRootPart").CFrame = AttackPart.CFrame
player.Character:WaitForChild("HumanoidRootPart").CFrame = EnemyPart.CFrame
player.Character.HumanoidRootPart.Anchored = true
player.Character.UpperTorso.CFrame = CFrame.new(-67.91, -224.94, 202.345) * CFrame.fromEulerAnglesXYZ(0,89.5,0)
local animationTrack = player.Character.Humanoid:LoadAnimation(script.Animations.EnemyAnim)
animationTrack:Play()
player.Character.Humanoid:TakeDamage(1)
end
wait(2.5)
local returnpart = game.Workspace.returnpart
print("testing")
player.Character.HumanoidRootPart.Anchored = false
plr.Character:WaitForChild("HumanoidRootPart").CFrame = returnpart.CFrame
player.Character:WaitForChild("HumanoidRootPart").CFrame = returnpart.CFrame
local animationTrack = player.Character.Humanoid:LoadAnimation(script.Animations.EnemyAnim)
animationTrack:Stop()
end)
end
end)

1 comment
It could be that you looped the animation while making it. Try checking that