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)
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.
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.