BodyVelocity Issue

So I understand bodyVelocity is depecrated, it’s just that none of the nondeprecated alternatives work as I want. Right now I’m just trying to make a simple dash, but an issue I’m noticing in some weird inconsistencies between testing in studio and actual playtesting.

Here it is in studio:


And here it is on playtest:

As you can see, the playtest one moves you a much smaller distance for some reason. And I am creating the bodyVelocity on the client.

here’s the code:

local bv = Instance.new("BodyVelocity")
bv.Parent = HumanoidRootPart
bv.MaxForce = Vector3.new(math.huge,0,math.huge)
for i = 80,0,-2 do
	if bv.Parent ~= nil then
		bv.Velocity = HumanoidRootPart.CFrame.LookVector * i	
		task.wait()	
	end
end
bv:Destroy()

And the strangest thing, is that when I watch other players try and use the dash, it goes back to the same speed as it is in studio. (I wasn’t able to capture this) And is why I even consider this an issue, because of the weird inconsistencies between players, studio, and playtesting. And like I said I’ve tried other alternatives to bodyVelocity, but none of them seem to work for a dash ability like I want.

While I am not entirely sure why its inconsistent, it seems like you are using differing speeds on the Velocity every 1/60 second. While what you have now can give the affect of slowing momentum, the quick shifts in the velocity probably aren’t that noticeable. A better alternative is to just do:

bv.Velocity = HumanoidRootPart.CFrame.LookVector * 40 -- or whatever number	
task.delay(0.6,function() 
   bv:Destroy()
end)

Also, I’m unsure what you were unable to achieve using the LinearVelocity alternative, but if you were concerned about the player not falling down from gravity, you should check out my response HERE as it resolves that issue.

Why not just tween the bodyVelocities velocity rather than doing it using a for i loop?

have u tried :ApplyImpulse()? though i dont think u can adjust the speed

I need the velocity to be in the direction the player is facing. Tweening it would send them in a straight line.

I have, but applyImpulse seems to send you further in the air due to friction, which isn’t what I want. Plus I want it to be affected by gravity which I don’t believe applyImpulse allows you to do

I’ve just tried it with LinearVelocity, but I get the same result, like exactly the same, it still looks different between studio and playtest:


And changing the velocity every tick was intentional, I need it to slow down over time and the difference between that and only setting the velocity once is very noticeable.

what exactly is the issue and adress the prompt to me as im too lazy to read

Im making a dash and both bodyVelocity and LinearVelocity have some weird inconsistencies between studio and playtesting. So I’m trying to figure out how to fix that or find some alternative

Don’t use BodyVelocity because it’s deprecated, it’s destined to be buggy. What inconsistencies are you experiencing with LinearVelocity?

some alternative:

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")

local dashDistance = 50 -- Adjust the distance of the dash
local dashTime = 0.5 -- Time in seconds for the dash to complete

local function dash()
    local direction = HumanoidRootPart.CFrame.LookVector
    local targetPosition = HumanoidRootPart.Position + direction * dashDistance
    local targetCFrame = CFrame.new(targetPosition)

    local tweenInfo = TweenInfo.new(
        dashTime, -- Duration
        Enum.EasingStyle.Linear, -- Easing style
        Enum.EasingDirection.Out, -- Easing direction
        0, -- Number of times to repeat
        false, -- Should it reverse
        0 -- Delay time
    )

    local tween = TweenService:Create(HumanoidRootPart, tweenInfo, {CFrame = targetCFrame})
    tween:Play()
    tween.Completed:Wait() -- Optional: Wait for the dash to complete before continuing
end

-- Trigger the dash (this could be connected to a key press or any other event)
dash()
  • uses tweenserivce
1 Like

or this

local lv = Instance.new("LinearVelocity")
lv.Parent = HumanoidRootPart
lv.MaxForce = Vector3.new(math.huge, 0, math.huge)
lv.Velocity = HumanoidRootPart.CFrame.LookVector * 80
game:GetService("Debris"):AddItem(lv, 0.5) -- Adjust the time as needed
  • linear velocity uses

I shared it in this post.

Those two clips are both using linearVelocity

Tweenservice does not work in my case. I want the dash to move the player in the direction they’re facing, allowing them to turn mid dash. Tweenservice sends them in a straight line along with being a bit jittery

1 Like

of course let me know when you need help ill return later this night. i have plans but ill come with the scripts later

Here’s an approach that uses a RunService loop to update the player’s velocity, allowing for direction changes mid-dash. This method gives you direct control over the player’s movement, making it smoother and more responsive to input changes:

local runService = game:GetService("RunService")
local players = game:GetService("Players")

-- Assuming this script is a LocalScript under a StarterPlayerScripts or a similar location
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local dashSpeed = 100 -- Adjust the dash speed as needed
local dashTime = 0.5 -- Dash duration in seconds
local isDashing = false

local function startDash()
    if isDashing then return end
    isDashing = true

    local startTime = tick()
    local connection

    connection = runService.RenderStepped:Connect(function()
        local currentTime = tick()
        if currentTime - startTime <= dashTime then
            -- Update the velocity based on the current LookVector
            humanoidRootPart.Velocity = humanoidRootPart.CFrame.LookVector * dashSpeed
        else
            -- Stop the dash
            humanoidRootPart.Velocity = Vector3.new(0,0,0) -- You might want to adjust this to fall naturally
            isDashing = false
            connection:Disconnect()
        end
    end)
end

-- Example trigger to start the dash, you can replace this with your own trigger mechanism
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed then
        if input.KeyCode == Enum.KeyCode.Space then -- Change this to your preferred key
            startDash()
        end
    end
end)

Note: This script is designed to run on the client side (as a LocalScript)

Ok, I’ve tested this and realized the issue has nothing to do with bodyVelocity, its just that velocity seems to differ between studio and playtesting. I’ve just used your script and the same issue comes up, changing the player’s velocity in studio seems to send them way farther than actual playtesting.


Not sure if this a bug

Can you describe the issues more in detail so we can try to fix it ?

Well it’s pretty much as it looks, using bodyVelocity, LinearVelocity, VectorForce, or changing the players velocity manually, there seems to be a difference between doing so in roblox studio and doing it in an actual playtest. in this case of a dash, using any of them seems to send you twice as far in studio as it does in an actual playtest.

It might be just Roblox studio in some of these scenarios im sorry. Try using possible alternatives