How do I make my Marble jump using space bar?

I need help making my marble jump. I am making a marble run. I got the ball to work but I want it to jump by using the space bar. How do I do that?

I tried finding videos but I can’t find what I want or need.

1 Like

Apply an impulse to the marble whenever the spacebar is depressed

marble:ApplyImpulse(, jump_power, 0))

thanks! I’ve been looking everywhere for a code for it.

You can do this by adding an event listener for the “tap” event. You can register a function to this event and it will be called when the user taps the screen. You can read about this in the docs.
In your case the code would look something like this:

local function onTap(event)
    -- Do something

Runtime:addEventListener("tap", onTap)

I only can make it tap on screen, I am a good coder but I don’t really know if I can make a listener that listens if the spacebar is pressed. Kinda skill issue.

I think you can use ContextActionService:BindAction()

local function jump()
	-- maybe add some debounce
	marble:ApplyImpulse(, jump_power, 0))

ContextActionService:BindAction("jump", jump, true, Enum.KeyCode.Space)

How did you do the bounce pad thing?


local part = game.Workspace:FindFirstChild("MyPart") --Change the directory that directs it to your part

function onInputBegan(input)
  if input.KeyCode == Enum.KeyCode.Space then
    part.Body.Velocity =, 50, 0)