How to go about making a bike jump?

How would I go about making a bicycle jump? I’ve tried the following, where I already have a VectorForce controlling the forward movement of the bike. However, I’m unsure if a VectorForce is appropriate for making it jump, and I can’t think of alternative ways. This is what I’ve got and I’ve basically hit a brick wall in my brain from here. Any help is appreciated, thanks.

local HoldingSpace = false
local Jumping = false

function JumpChanged()
	while HoldingSpace do
		if not Jumping then
			Jumping = true
			
			Force.Force = Vector3.new(Force.Force.X, 1000, Force.Force.Z) -- increase the Y force by 1000
			
			repeat task.wait() until PlayerHasFinishedJumpAndIsBackOnTheGround -- dont know how to detect once the player is back on the ground
			
			Jumping = false -- player is on the ground! let us jump again!
		end
	end
end

UserInputService.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = true
		
		JumpChanged()
	end
end)

UserInputService.InputEnded:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = false
	end
end)
1 Like

Hey!

You can use a vectorforce, bodyforce, velocity and a pulse on an object.

By modifying certain values you can create many amazing things!

1 Like

Also, you can try this script:

local UserInputService = game:GetService("UserInputService")

local HoldingSpace = false
local Jumping = false

local function isPlayerOnTheGround() 
    return false
end

local function JumpChanged()
	while HoldingSpace do
		if not Jumping then
			Jumping = true
			Force.Force = Vector3.new(Force.Force.X, 1000, Force.Force.Z)
			repeat
				task.wait(0.1)
			until isPlayerOnTheGround()
			
			Jumping = false
		else
			task.wait(0.1)
		end
	end
end

UserInputService.InputBegan:Connect(function(Key, Processed)
    if not Processed and Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = true
		JumpChanged()
	end
end)

UserInputService.InputEnded:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.Space then
		HoldingSpace = false
	end
end)

You can use ApplyImpulse to give the bike instant velocity upward, also to detect when the bike is on ground you can use raycasting

1 Like

The question I’m asking is how would I detect if the player is on the ground? I don’t understand, you just copy and pasted my original script and added a function?

ApplyImpulse works well, but the bike tips forward instead of staying upright. The bike is massless, however.

Try using LinearVelocity or AssemblyLinearVelocity of a part.