local player = game:GetService("Players").LocalPlayer
local Character = player.Character
local humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local DivingAnimation = script:WaitForChild("Animation")
local DivingLoad = humanoid.Animator:LoadAnimation(DivingAnimation)
local RollingAnimation = script:WaitForChild("RollingAnim")
local RollingLoad = humanoid.Animator:LoadAnimation(RollingAnimation)
local function ChangeJumpPower(jumppower)
if Character ~= nil then
local humanoid = Character:FindFirstChild("Humanoid")
if humanoid ~= nil then
humanoid.JumpPower = jumppower
end
end
end
local function MidAirLongJumpHandler(actionName,userInputState,inputObject)
if userInputState == Enum.UserInputState.Begin then
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if not Debounce then
LongJumpDebounce = true
inDiving = true
Debounce = true
ChangeJumpPower(0)
DivingLoad:Play()
RootPart:ApplyImpulse(RootPart.CFrame.LookVector * (1050))
workspace.Gravity = 145.8
RootPart:ApplyImpulse(RootPart.CFrame.YVector * (200))
task.wait(0.25)
workspace.Gravity = 180.2
ChangeJumpPower(50)
humanoid.FreeFalling:Connect(function(active)
if inDiving then
if active then
return
else
DivingLoad:Stop()
RollingLoad:Play()
inDiving = false
task.wait(0.6)
LongJumpDebounce = false
Debounce = false
end
end
end)
end
end
end
end
ContextActionService:BindAction("Mid Air Long Jump", MidAirLongJumpHandler, true, Enum.KeyCode.X)
ContextActionService:SetPosition("Mid Air Long Jump", UDim2.new(0.100, 0,0.700, 0))
it works but how i make it better
for like example make it smother or use something other than applyimpulse
im not a good developer and im trying to learn how to make good code for the game