How to move a player forward while still having gravity

I’m trying to make a skating game and i have it so that when you start skating it pushes you forward at a constant rate using body velocity but when you go off a ledge or if you go up a slope it breaks, when going off a platform you float in the air.

set your maxvelocity y axis to 0

1 Like

what is it a value for? the part?

the bodyvelocity maxvelocity is a vector3, it will affect how you fall if the maxvelocity’s y axis isn’t 0

there’s no maxvelocity for body velocity

Try also doing that down.. you’ll have to test out different values. It’s there someplace.

so nothing im trying is working.
this is my code for the body velocity

local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local BV2 = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
BV2.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
			
while skating == true do
	wait()
	BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 30
	plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
BV:Destroy()

how would i edit this to make the player still be affected by gravity?

You can use a newer LinearVelocity. (It’s basically the same thing with more features.)


If you want to use a depreciated (less recommended) BodyVelocity, then do:

BV.MaxForce = Vector3.new(math.huge, 0, math.huge)

so 0 force is applied on the Y axis (up/down). This means it doesn’t affect the up and down movement of the BasePart (i.e. gravity, ramps, falling, etc will still work normally).

MaxForce

You may what to kick that in when they have air underfoot. Idk , you may want to try out a different command here. BodyVelocity replaces the entire velocity, including the vertical axis, which cancels gravity and makes the player float.. So maybe try AssemblyLinearVelocity. This looks good for this case. AssemblyLinearVelocity only on the horizontal axes keeps the existing vertical velocity untouched..

--LocalScript in StarterPlayerScripts
local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local root = chr:WaitForChild("HumanoidRootPart")

local speed = 24

while true do
    task.wait()
    local v = root.AssemblyLinearVelocity
    local forward = root.CFrame.LookVector * speed
    root.AssemblyLinearVelocity = Vector3.new(forward.X, v.Y, forward.Z)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.