Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Unable to set the velocity of a part?

Asked by 4 years ago

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.

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 CrazyCats84 154 — 4y
0
i'll try that Oxygen4Lyfe 408 — 4y
0
that works thx Oxygen4Lyfe 408 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

Ad

Answer this question