How can I make a controlled jump height script?

Hi there,

I’m looking to make a script that detects how long and how hard you press Spacebar, A.K.A. detect how much the character should jump based on the time they pressed Spacebar.

Let’s say I held Spacebar for .1 seconds, it should jump just slightly. However, if I hold it down for a full second, it jumps all the way.

I don’t know how I can replicate this, since I’m sort of an average scripter anyways.

Thanks!!!

1 Like

You can use UserInputService + repeat loops for that stuff

Yeah, so, how do I script this? Uh, I don’t really know how I can do this. Been searching on YouTube, DevForum, and everywhere, and even went as far as using AI to know how I can script this.

local uis = game.UserInputService
local InputEnd = false


InputBegan:Connect(function()
     InputEnd = false
     repeat wait() JumpHeight += 1 until InputEnd or JumpHeight == MaxJumpHeaight
end)

InputEnded:Connect(function()
     InputEnd = true
end)

something basic like this

Where does “InputBegan” and “InputEnded” come from? How can it detect the key “Spacebar” if it doesn’t even mention it?
There are a lot of missing variables. How can I connect InputBegan and InputEnded?
How can I also connect “JumpHeight”? By connect, I mean to assign a correct variable for it.

I’m not gonna give you an entire script tf is you talking about do some research about UserInputService

1 Like

I never told you to, I’m just saying that, jesus christ man. Anyways, thanks for your help.

1 Like