Advertisement
OnFireRobloxScriptin

Roblox Double Jump Script

Sep 20th, 2023 (edited)
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. --//Put under StarterCharacterScripts
  2. --//Variables
  3. local uis = game:GetService("UserInputService") --Gets the UserInputService in Roblox
  4. local humanoid = script.Parent:WaitForChild("Humanoid") --Gets the Player's Humanoid
  5. local doublejumped = false --Sets a variable called "doublejumped" to false
  6. local jumped = false --Sets a variable called "jumped" to false
  7.  
  8. --//Double Jump System
  9. uis.JumpRequest:Connect(function() --Triggers when player requests a jump
  10.     if not jumped then --If variable jump is false then
  11.         jumped = true --Set variable jump to true
  12.         if humanoid.FloorMaterial ~= Enum.Material.Air then --If the humanoid is not in the air (on the ground) then
  13.             doublejumped = false --They have not double jumped, so sets variable "doublejumped" to false
  14.             task.wait(0.2) --Self explanatory
  15.             jumped = false --Sets variable "jumped" to false
  16.         elseif not doublejumped then --if they have not double jumped then
  17.             humanoid:ChangeState(Enum.HumanoidStateType.Jumping) --Change the Humanoid state to jumping (makes humanoid jump)
  18.             doublejumped = true --Sets variable "doublejumped" to true
  19.             task.wait(0.2) --Self explanatory
  20.             jumped = false --Sets variable "jumped" to false
  21.         end
  22.     end
  23. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement