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.
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.
Apply an impulse to the marble whenever the spacebar is depressed
marble:ApplyImpulse(Vector3.new(0, 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
end
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(Vector3.new(0, jump_power, 0))
end
ContextActionService:BindAction("jump", jump, true, Enum.KeyCode.Space)
How did you do the bounce pad thing?
I
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 = Vector3.new(0, 50, 0)
end
end
InputService.InputBegan:Connect(onInputBegan)