Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to set the velocity of a part?

Whenever I try to set the Humanoid Root Part's velocity it just doesn't do anything.

local SpeedLimit = 13
while true do
    wait(0.01)
    local VX = math.clamp(HumanoidRootPart.Velocity.X, -SpeedLimit, SpeedLimit)
    local VY = math.clamp(HumanoidRootPart.Velocity.Y, -SpeedLimit, SpeedLimit)
    local VZ = math.clamp(HumanoidRootPart.Velocity.Z, -SpeedLimit, SpeedLimit)
    HumanoidRootPart.Velocity = Vector3.new(VX, VY, VZ)
end
  • There are no errors
  • This is a server script
  • I can verify that it is running because if I put prints in it they print

It just doesn't set the velocity for some unknown reason.

3 comments

1

Try Getting a script that Creates a Bodyvelocity inside the rootpart, then edit the X,Y and Z positions, maybe? i'm not that good with velocities

0

i'll try that

0

that works thx

1 answer

✓ Accepted answer

Usually when trying to cause motion in parts you may want to use BodyMovers you can read about them here In this case BodyVelocity is what you want Using local BV = Instance.new('BodyVelocity')

Now how to directly apply this to your code

local SpeedLimit = 13
        Using local BV = Instance.new('BodyVelocity')
        BV.Parent = HumanoidRootPart --Assuming you declared HumanoidRootPart in your full code based on the code you proved
	while true do
	    wait(0.01)
	    local VX = math.clamp(HumanoidRootPart.Velocity.X, -SpeedLimit, SpeedLimit)
	    local VY = math.clamp(HumanoidRootPart.Velocity.Y, -SpeedLimit, SpeedLimit)
	    local VZ = math.clamp(HumanoidRootPart.Velocity.Z, -SpeedLimit, SpeedLimit)
	    BV.Velocity = Vector3.new(VX, VY, VZ)
	end

This should work if you have any further questions I please comment further

This discussion is preserved as it was. New answers, comments, and votes are closed.