so I make coyote jumps by myself (kinda bad) because there was no post about these jumps before but now there is
here is the script I made
if there is a better version, pls tell me ;-;
(put it in StarterCharacterScripts)
robloxapp-20230514-2141599.wmv (3.2 MB)
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local cas = game:GetService("ContextActionService")
local runService = game:GetService("RunService")
local loopConnection
local coyoteTime = 0.5
local coyoteTimeCounter = coyoteTime
humanoid.StateChanged:Connect(function(old,new)
if old == Enum.HumanoidStateType.Landed and new == Enum.HumanoidStateType.Running then
if loopConnection then loopConnection:Disconnect() end
coyoteTimeCounter = coyoteTime
elseif old == Enum.HumanoidStateType.Running and new == Enum.HumanoidStateType.Freefall then
loopConnection = runService.Heartbeat:Connect(function(deltaTime)
coyoteTimeCounter -= deltaTime
end)
end
end)
local function onJump()
if humanoid and coyoteTimeCounter > 0 then
coyoteTimeCounter = 0
humanoid:ChangeState(Enum.HumanoidStateType.Jumping,true)
end
end
cas:BindAction("jumpAction",onJump,false,Enum.KeyCode.Space)