Trying to make orb jump

Im trying to make orb jump but when i press “space” moving stops and only jumps.

here is my code

human = script.Parent.Humanoid
ball = script.Parent.Ball

function move()
	
	if human.FloorMaterial ~= Enum.Material.Air then
		
		ball.Velocity = ball.Velocity + (human.MoveDirection * human.WalkSpeed)
	end
	
end

game:GetService("RunService").RenderStepped:Connect(move)

local uis = game:GetService("UserInputService")
local jumppower = "50"

		uis.InputBegan:Connect(function(i)
			if i.KeyCode == Enum.KeyCode.Space then
				ball.Velocity= Vector3.new(0,jumppower,0)
			end
		end)

What should i do?
Thanks.

You set the ball velocity in all directions but Y to 0. I recommend adding that vector to the current velocity. The ball keeps moving, but now also goes up more.

Also, I don’t see a debounce. If you don’t put one in, you can probably make an infinite jump.

Thanks for reply.
How can i add velocity to current speed without inputting?

I’m assuming this part of the script worked fine? You already know how to do this. Add the Vector3.new to ball.Velocity.

:wink:


What I want to tell is how will the input be perceived without the service?

oh, I understand your question now. You described the problem as stopping to jump. That means the input is fine. Leave everything else alone and fix the stopping problem.

		uis.InputBegan:Connect(function(i)
			if i.KeyCode == Enum.KeyCode.Space then
				ball.Velocity= ball.Velocity + Vector3.new(0,jumppower,0)
			end
		end)

The good news is what you described as the problem is exactly what you told the ball to do. Velocity is speed. You said stop all movement in all directions and jump. All you need to do to fix that is remove the stop.

1 Like

Thanks a lot for your help. It works great!
I learned something new :blush:

1 Like