• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


01 Dec, 2024

Updated at 14 Dec, 2024

How to detect that player is on the ground when they want to jump?

Hello! Im currently working on the Advanced Run script, and there is acceleration system. You run faster as you gain more acceleration, you can currently do that by 2 ways:

  1. Run nonstop on the ground
  2. Jump while running

And first way seems to work alright with this part of script:

				if humanoid.MoveDirection.Magnitude > 0 and not braking then -- if humanoid moves and not braking
					if humanoid:GetState() == Enum.HumanoidStateType.Running then 
						accelerationPercent.Value = math.clamp(accelerationPercent.Value+1, 0, 100)
					end
				end

Although, when i tried to make the same for jump with checking humanoid’s state, for some reason it won’t add acceleration after jump:

	player.CharacterAdded:Connect(function(character)
		local hrp:Part = character:FindFirstChild("HumanoidRootPart")
		local humanoid:Humanoid = character:WaitForChild("Humanoid")

		--onJumpRequestRemote.OnServerEvent:Connect(function(plr)
		--if plr ~= player then return nil end

		humanoid:GetPropertyChangedSignal("Jump"):Connect(function() print(1)
			local humState = humanoid:GetState() 

			if humState ~= Enum.HumanoidStateType.Freefall and humanoid.MoveDirection.Magnitude > 0 and not braking then 
				if not jumpAccelerationCooldown then 
					jumpAccelerationCooldown = true
					accelerationPercent.Value = math.clamp(accelerationPercent.Value+3, 0, 100)
					task.wait(0.2)
					jumpAccelerationCooldown = false
				end
			else
				print(humState)
			end
		end)
	end)

It works like more than 50% of time, but i hope to find more accurate way so i will appreciate any help!

1 post - 1 participant

Read full topic