I want to (the question), I searched all over for something like this, just found how to make a double jump script, completely contrasting my question.
~~Here's my script~~
local UserInputService = game:GetService("UserInputService") local LshiftKey = Enum.KeyCode.LeftShift local SpaceKey = Enum.KeyCode.Space local function IsShiftKeyDown() return UserInputService:IsKeyDown(LshiftKey) end local function SpaceKeyDown() return UserInputService:IsKeyDown(SpaceKey) end local function KeyPressed(input) if IsShiftKeyDown() then script.Parent.Humanoid.WalkSpeed = 32 else script.Parent.Humanoid.WalkSpeed = 16 end if SpaceKeyDown() then wait(0.005) script.Parent.Humanoid.WalkSpeed = 32 wait(0.2) script.Parent.Humanoid.WalkSpeed = 16 end end UserInputService.InputBegan:Connect(KeyPressed) UserInputService.InputEnded:Connect(KeyPressed)
At lines 20 to 25, it fires first time when the player jumps (with the spacebar held), then after > 1 jumps, it fires randomly.
( Important Note: This script is very basic as my scripting knowledge isn't that high (which is probably a problem considering the question). I'll try to understand if I get any complex answers and probably ask dumb questions regarding it. Really hope I was as constructive as possible to my current question. )
Local script in StarterGui:
db = true game:GetService("UserInputService").InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Space then if db == true then plr = game.Players.LocalPlayer char = plr.Character char.Humanoid.JumpPower = 0 db = false wait(5) db = true char.Humanoid.JumpPower = 50 end end end)
That script should make the player only be able to jump every five seconds.
If this helped please up vote and accept this answer.
All the best,
PrismaticFruits
BIG THANKS to PrismaticFruits for the sample script, which helped me frame my answer
I implemented some parts of Prismatic's Sample script, and it worked! Here's the final answer.
local db = 0 local UserInputService = game:GetService("UserInputService") local LshiftKey = Enum.KeyCode.LeftShift local SpaceKey = Enum.KeyCode.Space local function IsShiftKeyDown() return UserInputService:IsKeyDown(LshiftKey) end local function SpaceKeyDown() return UserInputService:IsKeyDown(SpaceKey) end local function KeyPressed(input, gameProcessedEvent) if IsShiftKeyDown() then script.Parent.Humanoid.WalkSpeed = 32 else script.Parent.Humanoid.WalkSpeed = 16 end if SpaceKeyDown() then if db == 0 then wait(0.005) script.Parent.Humanoid.WalkSpeed = 32 wait(0.2) script.Parent.Humanoid.WalkSpeed = 16 script.Parent.Humanoid.JumpPower = 0 db = 1 UserInputService.InputEnded:Wait() if not SpaceKeyDown() then db = 0 script.Parent.Humanoid.JumpPower = 50 end end end end local function changejump(input) if not SpaceKeyDown() then db = 0 script.Parent.Humanoid.JumpPower = 50 end end UserInputService.InputBegan:Connect(KeyPressed) UserInputService.InputEnded:Connect(KeyPressed) UserInputService.InputEnded:Connect(changejump)