Animation Not working

Hello Developers, I’m having a problem with my stamina system. When the value hits 4 it supposed to stop the animation from playing until the value released from 4. But when the value hits 4 the animations is still playing. Please help

Code:

local TService = game:GetService('TweenService')
local IService = game:GetService('UserInputService')
local Camera = game.Workspace.CurrentCamera
local RService = game:GetService('RunService')
local Character = script.Parent
local Human = script.Parent:WaitForChild('Humanoid', 3)
local Anims = script:WaitForChild('Anims')
local STV = game.Players.LocalPlayer.Character:WaitForChild('HumanVals').HumanWS

local SprintTorso = Human:LoadAnimation(Anims.SprintTorso)
local SprintLimbs = Human:LoadAnimation(Anims.SprintLimbs)

local IsSprinting, SprintAnimPlaying = false, false

	IService.InputBegan:Connect(function(Input, gameProccesedEvent)
		if Input.KeyCode == Enum.KeyCode.Q then
		IsSprinting = true
			Human.WalkSpeed = 25
		end
	end)
	IService.InputEnded:Connect(function(Input, gameProccesedEvent)
		if Input.KeyCode == Enum.KeyCode.Q then
		IsSprinting = false
			Human.WalkSpeed = 14
		end
end)

RService.RenderStepped:Connect(function()
	if IsSprinting and Human.MoveDirection.Magnitude > 0 then
		
		if Human:GetState() == Enum.HumanoidStateType.Running or Human:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
			if not SprintAnimPlaying then
				SprintLimbs:Play()
				SprintTorso:Play()
				SprintAnimPlaying = true
			end
		else
			if SprintAnimPlaying then
				SprintLimbs:Stop()
				SprintTorso:Stop()
				SprintAnimPlaying = false
			end
			if STV.Value == 4 then
				SprintLimbs:Stop()
				SprintTorso:Stop()
				SprintAnimPlaying = false
			end
		end
	else
		if SprintAnimPlaying then
			SprintLimbs:Stop()
			SprintTorso:Stop()
			SprintAnimPlaying = false
		end
	end
end)

Instead of checking if the stamina is equal to 4, using this code:

STV.Value == 4 

Check if the stamina is less than or equal to 4, using the following:

STV.Value <= 4 

Thanks for the attempting to help but that sadly didn’t fix it.

That was just a general change which you should’ve made anyway, I’ll take a look at the entire script when I have some spare time.

1 Like