Landing Animation Error

Hello, I’m currently experiencing a problem with my game. When I jump and land on the floor the Idle animation should resume, but instead it just plays the sprint animation very slowly. Does anybody know how to fix this? thanks. I’m very new to Roblox Studio.
Here’s the video.
robloxapp-20230819-1145452.wmv (1.1 MB)

5 Likes

Sometimes the Humanoid state can go from Landed to Running, even if your character isn’t moving. Try checking if that’s the issue here.

Thanks for the response. I know this sounds dumb, but how would I check that?

You can check it via the StateChanged event in a Humanoid. Here’s an example:

local Human: Humanoid = script.Parent:WaitForChild("Humanoid")

Human.StateChanged:Connect(function(Old, New)
	print(Old, New)
end)

voila
image

Where would the text you provided appear?

Output.

I have that open, but nothing like that is appearing.

Is it a localscript in StarterCharacterScripts? Sorry, I should of noted on that

Oh, it isn’t. Let me fix that.

How does your animation script work by the way?

Oh, I would have no idea, sorry. I was following a tutorial and the uploader provided it. I’m just animating the character.
Here’s the script, though.
function waitForChild(parent, childName)
local child = parent:findFirstChild(childName)
if child then return child end
while true do
child = parent.ChildAdded:wait()
if child.Name==childName then return child end
end
end

local Player = game.Players.LocalPlayer
local Figure = workspace:WaitForChild(Player.Name)
local Humanoid = waitForChild(Figure, “Humanoid”)
local pose = “Standing”

local currentAnim = “”
local currentAnimInstance = nil
local currentAnimTrack = nil
local currentAnimKeyframeHandler = nil
local currentAnimSpeed = 1.0

local runAnimTrack = nil
local runAnimKeyframeHandler = nil

local priorityOrder = {
[Enum.AnimationPriority.Core] = 0,
[Enum.AnimationPriority.Idle] = 1,
[Enum.AnimationPriority.Movement] = 2,
[Enum.AnimationPriority.Action] = 3,
}

local animTable = {}
local animNames = {
idle = {
{ id = “rbxassetid://14493797210”, weight = 11 },
–[[
{ id = “http://www.roblox.com/asset/?id=11780781066”, weight = 1 },
{ id = “http://www.roblox.com/asset/?id=11780781066”, weight = 9 }
–]]
},
walk = {
{ id = “rbxassetid://14492170123”, weight = 60 }
},
spring = {
{ id = “rbxassetid://11780777835”, weight = 20 }
},
run = {
{ id = “rbxassetid://14492634767”, weight = 50 }
},
swim = {
{ id = “http://www.roblox.com/asset/?id=507784897”, weight = 10 }
},
swimidle = {
{ id = “http://www.roblox.com/asset/?id=507785072”, weight = 10 }
},
jump = {
{ id = “rbxassetid://11780777835”, weight = 10 }
},
fall = {
{ id = “rbxassetid://14494613544”, weight = 10 }
},
climb = {
{ id = “http://www.roblox.com/asset/?id=507765644”, weight = 10 }
},
sit = {
{ id = “http://www.roblox.com/asset/?id=507768133”, weight = 10 }
},
toolnone = {
{ id = “http://www.roblox.com/asset/?id=507768375”, weight = 10 }
},
toolslash = {
{ id = “http://www.roblox.com/asset/?id=507768375”, weight = 10 }
– { id = “slash.xml”, weight = 10 }
},
toollunge = {
{ id = “http://www.roblox.com/asset/?id=507768375”, weight = 10 }
},
wave = {
{ id = “http://www.roblox.com/asset/?id=507770239”, weight = 10 }
},
point = {
{ id = “http://www.roblox.com/asset/?id=507770453”, weight = 10 }
},
dance = {
{ id = “http://www.roblox.com/asset/?id=507771019”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507771955”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507772104”, weight = 10 }
},
dance2 = {
{ id = “http://www.roblox.com/asset/?id=507776043”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507776720”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507776879”, weight = 10 }
},
dance3 = {
{ id = “http://www.roblox.com/asset/?id=507777268”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507777451”, weight = 10 },
{ id = “http://www.roblox.com/asset/?id=507777623”, weight = 10 }
},
laugh = {
{ id = “http://www.roblox.com/asset/?id=507770818”, weight = 10 }
},
cheer = {
{ id = “http://www.roblox.com/asset/?id=507770677”, weight = 10 }
},
}

local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

math.randomseed(tick())

function configureAnimationSet(name, fileList)
if (animTable[name] ~= nil) then
for _, connection in pairs(animTable[name].connections) do
connection:disconnect()
end
end
animTable[name] = {}
animTable[name].count = 0
animTable[name].totalWeight = 0
animTable[name].connections = {}

local allowCustomAnimations = true
local AllowDisableCustomAnimsUserFlag = true

local success, msg = pcall(function()
	AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims")
end)

if (AllowDisableCustomAnimsUserFlag) then
	local ps = game:GetService("StarterPlayer"):FindFirstChild("PlayerSettings")
	if (ps ~= nil) then
		allowCustomAnimations = not require(ps).UseDefaultAnimations
	end
end

-- check for config values
local config = script:FindFirstChild(name)
if (allowCustomAnimations and config ~= nil) then
	table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
	table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
	local idx = 1
	for _, childPart in pairs(config:GetChildren()) do
		if (childPart:IsA("Animation")) then
			table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
			animTable[name][idx] = {}
			animTable[name][idx].anim = childPart
			local weightObject = childPart:FindFirstChild("Weight")
			if (weightObject == nil) then
				animTable[name][idx].weight = 1
			else
				animTable[name][idx].weight = weightObject.Value
			end
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight

– print(name … " [" … idx … “] " … animTable[name][idx].anim.AnimationId … " (” … animTable[name][idx].weight … “)”)
idx = idx + 1
end
end
end

-- fallback to defaults
if (animTable[name].count <= 0) then
	for idx, anim in pairs(fileList) do
		animTable[name][idx] = {}
		animTable[name][idx].anim = Instance.new("Animation")
		animTable[name][idx].anim.Name = name
		animTable[name][idx].anim.AnimationId = anim.id
		animTable[name][idx].weight = anim.weight
		animTable[name].count = animTable[name].count + 1
		animTable[name].totalWeight = animTable[name].totalWeight + anim.weight

– print(name … " [" … idx … “] " … anim.id … " (” … anim.weight … “)”)
end
end
end

– Setup animation objects
function scriptChildModified(child)
local fileList = animNames[child.Name]
if (fileList ~= nil) then
configureAnimationSet(child.Name, fileList)
end
end

script.ChildAdded:connect(scriptChildModified)
script.ChildRemoved:connect(scriptChildModified)

for name, fileList in pairs(animNames) do
configureAnimationSet(name, fileList)
end

– ANIMATION

– declarations
local toolAnim = “None”
local toolAnimTime = 0

local jumpAnimTime = 0
local jumpAnimDuration = .65

local toolTransitionTime = 0.1
local fallTransitionTime = 0.2

– functions

function stopAllAnimations()
local oldAnim = currentAnim

-- return to idle if finishing an emote
if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
	oldAnim = "idle"
end

currentAnim = ""
currentAnimInstance = nil
if (currentAnimKeyframeHandler ~= nil) then
	currentAnimKeyframeHandler:disconnect()
end

if (currentAnimTrack ~= nil) then
	currentAnimTrack:Stop()
	currentAnimTrack:Destroy()
	currentAnimTrack = nil
end

-- clean up walk if there is one
if (runAnimKeyframeHandler ~= nil) then
	runAnimKeyframeHandler:disconnect()
end

if (runAnimTrack ~= nil) then
	runAnimTrack:Stop()
	runAnimTrack:Destroy()
	runAnimTrack = nil
end

return oldAnim

end

local smallButNotZero = 0.0001
local startTween = 1.35
local endTween = 2

function setRunSpeed(speed)
if speed < startTween then
currentAnimTrack:AdjustWeight(1.0)
runAnimTrack:AdjustWeight(smallButNotZero)
elseif speed < endTween then
local weight = ((speed - startTween) / (endTween-startTween))
currentAnimTrack:AdjustWeight(1.0 - weight + smallButNotZero)
runAnimTrack:AdjustWeight(weight + smallButNotZero)
else
currentAnimTrack:AdjustWeight(smallButNotZero)
runAnimTrack:AdjustWeight(1.0)
end

local speedScaled = speed * 1.25
runAnimTrack:AdjustSpeed(speedScaled)
currentAnimTrack:AdjustSpeed(speedScaled)

end

function setAnimationSpeed(speed)
if speed ~= currentAnimSpeed then
currentAnimSpeed = speed
if currentAnim == “walk” then
setRunSpeed(speed)
else
currentAnimTrack:AdjustSpeed(currentAnimSpeed)
end
end
end

function keyFrameReachedFunc(frameName)
– print("CurrentAnim ", currentAnim, " ", frameName)
if (frameName == “End”) then
if currentAnim == “walk” then
runAnimTrack.TimePosition = 0.0
currentAnimTrack.TimePosition = 0.0
else
– print("Keyframe : "… frameName)

		local repeatAnim = currentAnim
		-- return to idle if finishing an emote
		if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
			repeatAnim = "idle"
		end
		
		local animSpeed = currentAnimSpeed
		playAnimation(repeatAnim, 0.15, Humanoid)
		setAnimationSpeed(animSpeed)
	end
end

end

function customKeycode(thisAnimTrack,name)
if thisAnimTrack.WeightCurrent < .1 then
return
end

for _,anim in pairs(Humanoid:GetPlayingAnimationTracks()) do
	if anim.IsPlaying and priorityOrder[thisAnimTrack.Priority] < priorityOrder[anim.Priority] then
		if anim.WeightCurrent > .5 then
			return
		end
	end
end

if name == "Footstep" then
	local volume = math.min(.15 + _G.Player.moveSpeed/67.5,.9)
	_G.playSound("concreteFootstep",false,volume)
end

end

function rollAnimation(animName)
local roll = math.random(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
return idx
end

function playAnimation(animName, transitionTime, humanoid)

local idx = rollAnimation(animName)

– print(animName … " " … idx … " [" … origRoll … “]”)

local anim = animTable[animName][idx].anim

-- switch animation		
if (anim ~= currentAnimInstance) then
	
	if (currentAnimTrack ~= nil) then
		currentAnimTrack:Stop(transitionTime)
		currentAnimTrack:Destroy()
	end

	if (runAnimTrack ~= nil) then
		runAnimTrack:Stop(transitionTime)
		runAnimTrack:Destroy()
	end

	currentAnimSpeed = 1.0

	-- load it to the humanoid; get AnimationTrack
	currentAnimTrack = humanoid:LoadAnimation(anim)
	 
	-- play the animation
	currentAnimTrack:Play(transitionTime)
	currentAnim = animName
	currentAnimInstance = anim
	
	local thisAnimTrack = currentAnimTrack
	currentAnimTrack.KeyframeReached:connect(function(name)
		customKeycode(thisAnimTrack,name)
	end)

	-- set up keyframe name triggers
	if (currentAnimKeyframeHandler ~= nil) then
		currentAnimKeyframeHandler:disconnect()
	end
	currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
	
	-- check to see if we need to blend a walk/run animation
	if animName == "walk" then
		local runAnimName = "run"
		local runIdx = rollAnimation(runAnimName)

		runAnimTrack = humanoid:LoadAnimation(animTable[runAnimName][runIdx].anim)		 
		runAnimTrack:Play(transitionTime)	
		
		if (runAnimKeyframeHandler ~= nil) then
			runAnimKeyframeHandler:disconnect()
		end
		runAnimKeyframeHandler = runAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
		
		runAnimTrack.KeyframeReached:connect(function(name)
			customKeycode(runAnimTrack,name)
		end)
	end
end

end



local toolAnimName = “”
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil

function toolKeyFrameReachedFunc(frameName)
if (frameName == “End”) then
– print("Keyframe : "… frameName)
playToolAnimation(toolAnimName, 0.0, Humanoid)
end
end

function playToolAnimation(animName, transitionTime, humanoid)

	local idx = rollAnimation(animName)

– print(animName … " * " … idx … " [" … origRoll … “]”)
local anim = animTable[animName][idx].anim

	if (toolAnimInstance ~= anim) then
		
		if (toolAnimTrack ~= nil) then
			toolAnimTrack:Stop()
			toolAnimTrack:Destroy()
			transitionTime = 0
		end
				
		-- load it to the humanoid; get AnimationTrack
		toolAnimTrack = humanoid:LoadAnimation(anim)
		 
		-- play the animation
		toolAnimTrack:Play(transitionTime)
		toolAnimName = animName
		toolAnimInstance = anim

		currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
	end

end

function stopToolAnimations()
local oldAnim = toolAnimName

if (currentToolAnimKeyframeHandler ~= nil) then
	currentToolAnimKeyframeHandler:disconnect()
end

toolAnimName = ""
toolAnimInstance = nil
if (toolAnimTrack ~= nil) then
	toolAnimTrack:Stop()
	toolAnimTrack:Destroy()
	toolAnimTrack = nil
end


return oldAnim

end



function onRunning(speed)
if speed > 0.01 then
local scale = 32.0 --Determines how soon it eases into the run animation
playAnimation(“walk”, 0.1, Humanoid)
setAnimationSpeed(speed / scale)
pose = “Running”
else
if emoteNames[currentAnim] == nil then
playAnimation(“idle”, 0.1, Humanoid)
pose = “Standing”
end
end
end

function onDied()
pose = “Dead”
end

function onJumping()
playAnimation(“jump”, 0.1, Humanoid)
jumpAnimTime = jumpAnimDuration
pose = “Jumping”
end

function onClimbing(speed)
local scale = 5.0
playAnimation(“climb”, 0.1, Humanoid)
setAnimationSpeed(speed / scale)
pose = “Climbing”
end

function onGettingUp()
pose = “GettingUp”
end

function onFreeFall()
if (jumpAnimTime <= 0) then
playAnimation(“fall”, fallTransitionTime, Humanoid)
end
pose = “FreeFall”
end

function onFallingDown()
pose = “FallingDown”
end

function onSeated()
pose = “Seated”
end

function onPlatformStanding()
pose = “PlatformStanding”
end

function onSwimming(speed)
if speed > 1.00 then
local scale = 10.0
playAnimation(“swim”, 0.4, Humanoid)
setAnimationSpeed(speed / scale)
pose = “Swimming”
else
playAnimation(“swimidle”, 0.4, Humanoid)
pose = “Standing”
end
end

function getTool()
for _, kid in ipairs(Figure:GetChildren()) do
if kid.className == “Tool” then return kid end
end
return nil
end

function animateTool()

if (toolAnim == "None") then
	playToolAnimation("toolnone", toolTransitionTime, Humanoid)
	return
end

if (toolAnim == "Slash") then
	playToolAnimation("toolslash", 0, Humanoid)
	return
end

if (toolAnim == "Lunge") then
	playToolAnimation("toollunge", 0, Humanoid)
	return
end

end

function getToolAnim(tool)
for _, c in ipairs(tool:GetChildren()) do
if c.Name == “toolanim” and c.className == “StringValue” then
return c
end
end
return nil
end

local lastTick = 0

function move(time)
local amplitude = 1
local frequency = 1
local deltaTime = time - lastTick
lastTick = time

local climbFudge = 0
local setAngles = false

if (jumpAnimTime > 0) then
	jumpAnimTime = jumpAnimTime - deltaTime
end

if (pose == "FreeFall" and jumpAnimTime <= 0) then
	playAnimation("fall", fallTransitionTime, Humanoid)
elseif (pose == "Running") then
	playAnimation("walk", 0.1, Humanoid)
elseif (pose == "PlatformStanding") then
	playAnimation("spring", 0.1, Humanoid)
elseif (pose == "Seated") then
	playAnimation("sit", 0, Humanoid)
elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown") then
	stopAllAnimations()
	amplitude = 0.1
	frequency = 1
	setAngles = true
end

-- Tool Animation handling
local tool = getTool()
if tool and (tool.RequiresHandle or tool:FindFirstChild("Handle")) then

	local animStringValueObject = getToolAnim(tool)

	if animStringValueObject then
		toolAnim = animStringValueObject.Value
		-- message recieved, delete StringValue
		animStringValueObject.Parent = nil
		toolAnimTime = time + .3
	end

	if time > toolAnimTime then
		toolAnimTime = 0
		toolAnim = "None"
	end

	animateTool()		
else
	stopToolAnimations()
	toolAnim = "None"
	toolAnimInstance = nil
	toolAnimTime = 0
end

end

– connect events
Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.Jumping:connect(onFreeFall)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)

– setup emote chat hook
game.Players.LocalPlayer.Chatted:connect(function(msg)
local emote = “”
if (string.sub(msg, 1, 3) == "/e ") then
emote = string.sub(msg, 4)
elseif (string.sub(msg, 1, 7) == "/emote ") then
emote = string.sub(msg, 8)
end

if (pose == "Standing" and emoteNames[emote] ~= nil) then
	playAnimation(emote, 0.1, Humanoid)
end

– print("===> " … string.sub(msg, 1, 3) … “(” … emote … “)”)
end)

– initialize to idle
playAnimation(“idle”, 0.1, Humanoid)

pose = “Standing”

– loop to handle timed state transitions and tool animations
while Figure.Parent~=nil do
local _, time = wait(0.1)
move(time)
end

Oh, so it just looks like the base Roblox animate script. I don’t know then, sorry. You will probably have to write your own animate script or something.

Oh, I have acceleration and momentum scripts that could be interfering.
Acceleration.

wait()

---v CONST VARIABLES v--- --DON'T CHANGE THESE <<<<<<

--v Services v--

local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")

--v Player and character v--

local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local HRP = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local BaseWalkSpeed = humanoid.WalkSpeed
local States = require(script.Parent:WaitForChild("States"))
local rings = workspace:WaitForChild("rings")

--v Camera v--

local cam = workspace.CurrentCamera
local baseFOV = cam.FieldOfView

local blur = Instance.new("BlurEffect", game:GetService("Lighting"))
blur.Enabled = false
blur.Size = 5

--v Permitting variables v--

local CanAccel
local CanBoost

local ElapsedTime = 0

local isBoosting = false
local canAirBoost = true

--v Sounds v--

local chargesound = script:WaitForChild("chargesound")
local releasesound = script:WaitForChild("releasesound")
local boostsound = script:WaitForChild("boostsound")
local airdashsound = script:WaitForChild("airdashsound")



---v CUSTOMIZABLE VARIABLES v--- --You can change these <<<<<<

--v Mach duration v--

--These determine how long you must be moving to speed up

local firstMachDuration = 1.1
local secondMachDuration = 3.3 + (firstMachDuration)
local thirdMachDuration = 4.9 + (secondMachDuration)

--v Speeds v--

--These determine the speed of each mach, as well as boost speed

local secondMachSpeed = 22
local thirdMachSpeed = 32
local topMachSpeed = 40
local boostSpeed = 45

--v Boost restrictions v--

--requiredSpeed is how fast the player must be moving to boost. Set to BaseWalkSpeed to allow the player to boost whenever.
--initialRingCost is how many rings get taken upon pressing the boost button. Set to 0 to remove.

local requiredSpeed = secondMachSpeed
local initialRingCost = 0

--NOTE: There are notes with a [!] farther down in case you want to change more

---v PARTICLE SETUP v---

local charge = script:WaitForChild("pending")
charge.Parent = HRP

local release = script:WaitForChild("changing")
release.Parent = HRP

local boosting = script:WaitForChild("boosting")
boosting.Parent = HRP

local airdashparticles = script:WaitForChild("particles")
airdashparticles.Parent = HRP



---v SCREEN EFFECTS v---

local tweeninf = TweenInfo.new(.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out)

local function BoostFX(stat)
	if stat then
		local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out)
		local pullBack = TS:Create(cam, tweeninfo, {FieldOfView = baseFOV + 30})
		pullBack:Play()
		blur.Enabled = true
	else
		local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
		local pullIn = TS:Create(cam, tweeninfo, {FieldOfView = baseFOV})
		pullIn:Play()
		blur.Enabled = true
	end
end

local function SpeedFX(stat, speed)
	if stat then
		if speed == 2 then
			local first = TS:Create(cam, tweeninf, {FieldOfView = baseFOV + 5})
			first:Play()
		elseif speed == 3 then
			local second = TS:Create(cam, tweeninf, {FieldOfView = baseFOV + 10})
			second:Play()
		elseif speed == 4 then
			local third = TS:Create(cam, tweeninf, {FieldOfView = baseFOV + 20})
			third:Play()
		end
	else
		local pullIn = TS:Create(cam, tweeninf, {FieldOfView = baseFOV})
		pullIn:Play()
	end
end



---v SPEED READER v---

humanoid.Running:Connect(function(speed)
	CanAccel = (speed > 1 and not isBoosting)
	CanBoost = (humanoid.WalkSpeed >= requiredSpeed and speed > 1)
end)



---v PARTICLES v---

local function Update(Time)
	if not isBoosting then
		if Time > firstMachDuration - 1.6 and Time < firstMachDuration - .1 then
			charge.Enabled = true
			
			if not chargesound.IsPlaying then
				chargesound:Play()
			end
		elseif Time > firstMachDuration - .1 and Time < firstMachDuration + .1 then
			charge.Enabled = false
			release.Enabled = true
			
			if not releasesound.IsPlaying then
				releasesound:Play()
				boostsound.Volume = .15
				boostsound:Play()
			end
			
			wait(.5)
			release.Enabled = false
		elseif Time > secondMachDuration - 1.6 and Time < secondMachDuration - .1 then
			charge.Enabled = true
			
			if not chargesound.IsPlaying then
				chargesound:Play()
			end
			
		elseif Time > secondMachDuration - .1 and Time < secondMachDuration + .1 then
			charge.Enabled = false
			release.Enabled = true
			
			if not releasesound.IsPlaying then
				releasesound:Play()
				boostsound.Volume = .15
				boostsound:Play()
			end
			
			wait(.5)
			release.Enabled = false
		elseif Time > thirdMachDuration - 1.6 and Time < thirdMachDuration - .1 then
			charge.Enabled = true
			
			if not chargesound.IsPlaying then
				chargesound:Play()
			end
		elseif Time > thirdMachDuration - .1 and Time < thirdMachDuration + .1 then
			charge.Enabled = true
			release.Enabled = false
			
			if not releasesound.IsPlaying then
				releasesound:Play()
				boostsound.Volume = .2
				boostsound:Play()
			end
		end
	end
end



---v BOOST v---

--v Boost function v--

local function Boost(stat, bypassAir, hasStopped)
	if stat and CanBoost then
		humanoid.WalkSpeed = boostSpeed
		release.Enabled = false
		charge.Enabled = false
		boosting.Enabled = true
	else
		if hasStopped == nil then
			ElapsedTime = thirdMachDuration - .1
			Update(ElapsedTime)
			blur.Enabled = false
			States:ChangeState(nil)
		else
			isBoosting = false
			CanAccel = true
			release.Enabled = false
			charge.Enabled = false
			boosting.Enabled = false
			ElapsedTime = 0
			Update(0)
			BoostFX(false)
			States:ChangeState(nil)
		end
	end
end

--v Start boosting v--

UIS.InputBegan:Connect(function(input)
	local button = input.KeyCode
	
	if (button == Enum.KeyCode.LeftShift or button == Enum.KeyCode.ButtonX) and humanoid.Health ~= 0 then
		if CanBoost and rings.Value > 0 then
			boostsound.Volume = .5
			boostsound:Play()
			States:ChangeState("boost")
			BoostFX(true)
			rings.Value = rings.Value - initialRingCost
			
			CanBoost = true
			isBoosting = true
			CanAccel = false
			
			if humanoid:GetState() == Enum.HumanoidStateType.Freefall and canAirBoost then --Remove everything between this "if" and "end" to remove air boost
				HRP.Velocity = HRP.CFrame:VectorToWorldSpace(Vector3.new(0, 100, -160)) --Change the Vector3 to modify the air boost. Keep the fisrt number at 0
				canAirBoost = false
			end
		else
			if humanoid:GetState() == Enum.HumanoidStateType.Freefall and canAirBoost and not isBoosting then --Remove everything from this "if" to the "end" to remove air dash
				States:ChangeState("boost")
				airdashsound:Play()
				HRP.Velocity = HRP.CFrame:VectorToWorldSpace(Vector3.new(0, 50, -120)) --Change the Vector3 to modify the air dash. Keep the fisrt number at 0
				canAirBoost = false
				airdashparticles.Enabled = true
				wait()
				States:ChangeState(nil)
				wait(.1)
				airdashparticles.Enabled = false
			end
		end
	end
end)

--v Stop boosting v--

UIS.InputEnded:Connect(function(input)
	local button = input.KeyCode
	
	if (button == Enum.KeyCode.LeftShift or button == Enum.KeyCode.ButtonX) and isBoosting and humanoid.Health ~= 0 then
		isBoosting = false
		CanAccel = true
		Boost(false)
		release.Enabled = false
		charge.Enabled = false
		boosting.Enabled = false
	end
end)



---v UPDATING v---

RS.Heartbeat:Connect(function(elapsed)
	if humanoid.Health ~= 0 then
		if humanoid:GetState() == Enum.HumanoidStateType.Landed then
			canAirBoost = true
		end
		
		if CanAccel == true and humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
			ElapsedTime = ElapsedTime + elapsed
			if ElapsedTime > firstMachDuration and ElapsedTime < secondMachDuration then
				humanoid.WalkSpeed = secondMachSpeed
				SpeedFX(true, 2)
			elseif ElapsedTime > secondMachDuration and ElapsedTime < thirdMachDuration then
				humanoid.WalkSpeed = thirdMachSpeed
				SpeedFX(true, 3)
			elseif ElapsedTime > thirdMachDuration then
				humanoid.WalkSpeed = topMachSpeed
				SpeedFX(true, 4)
			end
			Update(ElapsedTime)
		else
			if humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and States:GetState() == nil and not isBoosting then
				ElapsedTime = 0
				humanoid.WalkSpeed = BaseWalkSpeed
				release.Enabled = false
				charge.Enabled = false
				SpeedFX(false)
			end
			
			if isBoosting then
				Boost(true)
			end
		end
		
		if isBoosting then
			if not CanBoost and States:GetState() ~= "Spring" then
				isBoosting = false
				CanAccel = false
				Boost(false, nil, true)
				release.Enabled = false
				charge.Enabled = false
				boosting.Enabled = false
				wait()
				CanAccel = false
			end
			
			if rings.Value == 0 then
				isBoosting = false
				CanAccel = true
				Boost(false)
				boosting.Enabled = false
				BoostFX(false)
			end
		end
		
		if States:GetState() == "hurt" then
			isBoosting = false
			CanAccel = false
			Boost(false, nil, true)
			release.Enabled = false
			charge.Enabled = false
			boosting.Enabled = false
			humanoid.WalkSpeed = BaseWalkSpeed
		end
		
		if States:GetState() == nil and isBoosting then
			States:ChangeState("boost")
		end
	end
end)



---v RESET CAM v---

humanoid.Died:Connect(function()
	isBoosting = false
	CanAccel = false
	blur:Destroy()
	Boost(false, nil, true)
end)

Momentum

local TS = game:GetService("TweenService")

local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild('Humanoid')
local char = Player.Character

stat = Player:WaitForChild("Data")

while wait() do
      if Humanoid.MoveDirection == Vector3.new (0, 0, 0) then
		Humanoid.WalkSpeed = stat.StartSpeed.Value
	else
		Humanoid.WalkSpeed = Humanoid.WalkSpeed + stat.AddSpeed.Value
		if Humanoid.WalkSpeed >= stat.MaxSpeed.Value then
			Humanoid.WalkSpeed = stat.MaxSpeed.Value
		end
	end
end

Anybody know the issue? thanks