#i have a shift to sprint script but when i try to play a jump anim it starts playing over and over

7 messages · Page 1 of 1 (latest)

stoic perch
#

and no ai wont fix it ive tried multiple times

#

`local ContextActionService = game:GetService("ContextActionService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local Animation = script.SprintAnim
local SprintAnimation = animator:LoadAnimation(Animation)

local JumpAnimation = script.JumpAnim
local JumpAnimationTrack

local isJumping = false

function startSprinting()
character.Humanoid.WalkSpeed = 18
SprintAnimation:Play()
end

function endSprinting()
character.Humanoid.WalkSpeed = 9
SprintAnimation:Stop()
end

function moveDirectionCheck()
if humanoid.MoveDirection == Vector3.zero then
endSprinting()
end
end

function startJump()
if not JumpAnimationTrack or not JumpAnimationTrack.IsPlaying then
JumpAnimationTrack = animator:LoadAnimation(JumpAnimation)
JumpAnimationTrack:Play()
isJumping = true
end
end

function Sprint(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
startSprinting()
elseif inputState == Enum.UserInputState.End then
endSprinting()
end
end

function onJump(oldState, newState)
if oldState ~= Enum.HumanoidStateType.Jumping and newState == Enum.HumanoidStateType.Jumping and not isJumping then
local actionInfo = ContextActionService:GetBoundActionInfo("Sprint")
if actionInfo then
startSprinting()
end
startJump()
elseif newState == Enum.HumanoidStateType.Landed then
isJumping = false
startSprinting()
end
end

ContextActionService:BindAction("Sprint", Sprint, false, Enum.KeyCode.LeftShift)

humanoid.Changed:Connect(moveDirectionCheck)
humanoid.StateChanged:Connect(onJump)`

glad terrace
#

ai?

#

duh its bad

molten sandal
#

@stoic perch

glad terrace
#

aint no way you actually read that all