Creating Dashes Without Flinging

In my game I have multiple dashes/skills that have a dash combined with them. To create these dashes I use a Body Velocity in the Humanoid Root Part, but the only problem is if the player launches into any part they will fling and glitch. I have figured out a solution to this problem by using a render step connected with a touched event checking for a Body Velocity and deleting it then changing the Humanoid Root Part velocity to 0, but this creates major lag for the player anytime they touch anything. So I created a new script that still utilizes a value and remote event to enable the Render step with touched event, but disconnects the touch event after as well, but this script set up only has around 20% chance of actually working.

Local Script

wait(1)
Main = script.Parent.HumanoidRootPart
local RunService = game:GetService("RunService")
Bving = false
OnIt = false
event =  script.Parent.BvEvent

local function onRenderStep(deltaTime)
if Bving == false then
if script.Parent.BvOn.Value == true then
Bving = true			
Touching = Main.Touched:Connect(function(Part)
if Part.CanCollide == true then
Main.Velocity = Vector3.new()
Main.RotVelocity = Vector3.new()	
event:FireServer()
end
end)
repeat wait()
	
until script.Parent.BvOn.Value == false
Touching:Disconnect()
Bving = false
end
end
end
RunService.RenderStepped:Connect(onRenderStep)

Server Script

wait(1)
event = script.Parent.BvEvent
Main = script.Parent.HumanoidRootPart
event.OnServerEvent:connect(function()	
if script.Parent.BvOn.Value == true then
		if Main:FindFirstChild("BV")  then
		Main:FindFirstChild("BV"):remove()
			end	
		Main.Velocity = Vector3.new()
		Main.RotVelocity = Vector3.new()
		y = Instance.new("BodyVelocity")
		y.Name = "BV"
		y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		y.velocity = Main.CFrame.lookVector*0
		y.Parent = Main
		game.Debris:AddItem(y,0.001)	
		Main.Velocity = Vector3.new()
		Main.RotVelocity = Vector3.new()
		script.Parent.BvOn.Value = false	
end
end)

Both scripts, the value, and the remote event are placed inside the Player Character for every player.

5 Likes

Change the BodyVelocity’s MaxForce to something that isn’t math.huge. It can still be a high number, but having that high of a MaxForce causes the flinging.

24 Likes

Thank you, it works perfectly I feel kinda stupid for having trouble with such an easy fix.

im having this same issue can you tell me what u set MaxForce too in order to fix ur problem?

edit:nvm i figured out that setting it to 100000 fixed my issue

5 Likes

Thank you! I know this is from 2 years ago but this solved my problem!

you shouldnt be using bodyvelocity (its deprecated), use linearvelocity instead

I know that, It’s just that I ran into an issue where I was using math.huge as the maximum force for LinearVelocity.