Issue with animations not completing fully when playing and stopping animations to play other ones

So I am trying to create the pounce system from SCP:SL’s 939 (Not for an scp game but because I like it).

I realised when playing animations that they would completly run but then sort of “glitch out” to where the animation would end naturally however would seem to freeze the players model to a part of an animation despite an “idle” animation playing which in theory should have “reset” the players character.

Everything is done on the server. I know this isnt good in practice however there is only one player who plays as the “Predator” and it is only going to be a max server pop of 5-6 players so it really should not matter much.


Please ignore the transparent circles, it is from a plugin I use/used.

It is likely to be easier to understand if you look at the clip:


The code:

local Players = game:GetService("Players")

local TweenService = game:GetService("TweenService")

local Bridgenet = require()

local Predator_StartPounce = Bridgenet.CreateBridge("Predator_StartPounce")
local Predator_DoPounce = Bridgenet.CreateBridge("Predator_DoPounce")

local RayCastHitbox = require(game:GetService("ReplicatedStorage").RaycastHitboxV4)

local TI = TweenInfo.new(.9, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local PounceTI = TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)

local WalkSpeed = 20.275

local function StartPounce(player: Player)
	
	local Char = player.Character
	local Humanoid: Humanoid = Char:WaitForChild("Humanoid")
	local Animator: Animator = Humanoid:WaitForChild("Animator")
		
	local Tween = TweenService:Create(Humanoid, TI, { WalkSpeed = 0 })
	local anim: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("StartPounce"))
	local idle: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("IdlePounce"))
	
	Tween:Play()
	
	anim:Play()
	
	task.wait(.25)
	
	idle.Looped = true
	idle:Play()
	
	Tween.Completed:Wait()
	
	print(2)

	Humanoid:SetAttribute("IsPouncing", true)

end

local function DoPounce(player: Player)
	
	local Char = player.Character
	local Humanoid: Humanoid = Char:WaitForChild("Humanoid")
	local Animator: Animator = Humanoid:WaitForChild("Animator")

	local endP: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("EndPounce"))
	local inair: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("InAirPounce"))
	local anim: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("DoPounce"))
	local idle: AnimationTrack = Animator:LoadAnimation(Humanoid:WaitForChild("Idle"))

	anim:Play() 
	
    -- debug lol
	local part = Instance.new("Part")
	part.Parent = workspace
	part.Anchored = true
	part.Material = Enum.Material.Neon
	part.Color = Color3.new(0.917647, 1, 0.00784314)
	part.CanCollide = false
	
	-- calculate pounce distance
	local pounceDistance = 20
	local pounceHeight = 2.5
	local pounceDirection = Char.HumanoidRootPart.CFrame.LookVector
	local pouncePosition: Vector3 = Char.HumanoidRootPart.Position + (pounceDirection * pounceDistance) + Vector3.new(0, pounceHeight, 0)
	
	part.CFrame = CFrame.new(pouncePosition, Char.HumanoidRootPart.Position)
	
	inair.Looped = true
	inair:Play()
	
	local PosTween = TweenService:Create(Char.HumanoidRootPart, PounceTI, { CFrame = CFrame.new(pouncePosition, Char.HumanoidRootPart.Position) })
	PosTween:Play()

	PosTween.Completed:Wait()
	
	local Tween = TweenService:Create(Humanoid, TI, { WalkSpeed = 20.275 })
	Tween:Play()
	
	print(1)

	inair:Stop()
	endP:Play()
	
	print(endP.IsPlaying, inair.IsPlaying)
	
	endP.Ended:Wait()
	idle:Play()
	
	warn("Ended")
end


Issues:

  • Player model does not revert back to idle animation once the player has finished pouncing.

I know that the character does a 360 but that is only really due to me not controlling the player therefore nothing is correcting the lookvector. I will fix this later and this is a trashy mock up of the system but I want to fix the animations first.

I think of authiority of animation
idle supposed to idle (which probably doesn’t get to animated due to high authiority of different animation)
switch animation when it this animation stops

idlePounce is being looped and it’s playing

Youre right, i over looked that. Let me make some changes and ill post my findings.

FIxed the issue, forgot what exactly was the issue however here is part of my modified code.

local Tween = TweenService:Create(Humanoid, TI, { WalkSpeed = 20.275 })
	Tween:Play()
	
	print(1)
	
	inair.Looped = false
	
	inair:Stop(1)

	
	print(inair.TimePosition, inair.IsPlaying)
	
	--endP:Play(1)
	
	print(endP.IsPlaying, inair.IsPlaying)
	
	--endP.Ended:Wait()
	
	--[[idle.Looped = false
	idle:Play(.2)]]
	
	warn("Ended")
1 Like