Dash doesn't stop immediately after destroying velocity

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve a perfect smooth dashing system similar to TSB (The Strongest Battlegrounds)
  2. What is the issue? Include screenshots / videos if possible!
    I’ve managed to get pretty close to what I want. However the issue is the front dash doesn’t stop right after I destroy the BodyVelocity. It’s all handled on the server and the there is a radius hitbox to determine if you’re close enough to a player to destroy the velocity.
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using different objects which didn’t help because the newer ones don’t work good on serverside. I also made a bigger radius hitbox to destroy the velocity before you actually reach the player.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Any help or suggestions on this matter would be appreciated, if you have any questions please ask. Please try to be elaborate and clear with your responses.

Client Side Dash Function

function FrontDash(DashObject)
	if Running then
		Running = false
		Animations.Run:Stop()
	end
	HasFrontDash = false
	
	local DashDistance = Instance.new("NumberValue")
	DashDistance.Name = "FrontDashDistance"
	DashDistance.Parent = Character
	DashDistance.Value = 125
	
	local FrontDashTween = TweenService:Create(DashDistance, FrontDashInfo, {Value = 0})
	FrontDashTween:Play()
	
	local DashConnection = nil
	local StunConnection = nil
	
	StunConnection = Stunned.Changed:Connect(function(Stun)
		if Stun == true then
			FrontDashTween:Cancel()
		end
	end)
	
	coroutine.wrap(function()
		DashConnection = RunService.Heartbeat:Connect(function()
			DashObject.Velocity = HumanoidRootPart.CFrame.LookVector * DashDistance.Value
		end)
	end)()
	
	FrontDashTween.Completed:Connect(function()
		DashConnection:Disconnect()
		StunConnection:Disconnect()
		DashObject:Destroy()
		DashDistance:Destroy()
		
		coroutine.wrap(function()
			task.wait()
			HasFrontDash = true
		end)()
	end)
end

Hitbox Module Function

function CombatModule:DashEarlyStop(Character:Model?, HumanoidRootPart:BasePart, DashObject:BodyVelocity?, Animation:AnimationTrack?)
	local Hitbox = Meshes:FindFirstChild("DashRadiusHitbox"):Clone()
	Hitbox.Name = Character.Name.." ".. Hitbox.Name
	Hitbox.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,0,-10)
	
	local WeldConstraint = Instance.new("WeldConstraint")
	WeldConstraint.Part0 = HumanoidRootPart
	WeldConstraint.Part1 = Hitbox
	WeldConstraint.Parent = Hitbox
	
	Hitbox.Parent = Hitboxes
	Debris:AddItem(Hitbox, 0.4)
	
	local HitboxConnection = nil
	
	Hitbox.Destroying:Once(function()
		if HitboxConnection ~= nil then
			HitboxConnection:Disconnect()
		end
	end)
	
	coroutine.wrap(function()
		local Whitelist = {}
		
		HitboxConnection = RunService.Heartbeat:Connect(function()
			local HitboxResults = workspace:GetPartsInPart(Hitbox)
			
			for i,v in pairs(HitboxResults) do
				if not v:IsDescendantOf(Character) then
					local OtherHumanoid = v.Parent:FindFirstChild("Humanoid")
					
					if OtherHumanoid and OtherHumanoid.Health > 0 then
						local OtherCharacter = OtherHumanoid.Parent
						
						if not table.find(Whitelist, OtherCharacter) then
							local OtherRagdollTrigger = OtherCharacter:FindFirstChild("RagdollTrigger")
							
							if OtherRagdollTrigger.Value == false then
								HitboxConnection:Disconnect()
								DashObject:Destroy()
								table.insert(Whitelist, OtherCharacter)
								Hitbox:Destroy()
								
								if Animation.TimePosition < 0.75 then
									Animation.TimePosition = 0.75
								else
									break
								end
							end
						end
					end
				end
			end
			
		end)
	end)()
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

5 Likes