What's the best way to handle a dash system?

Currently I’m trying to make a dash system but I’m not sure on what’s the most efficient way in handling it.

Right now, it fires a request remote named ‘Dodge’ in the client and then the server does all the effects for that dash.

Client → Server

However, I’m curious about having the same as above but you FireAllClients back to the local script to do the effects there instead.

Client → Server → Client

I’m just wondering what work’s best performance wise and obviously for any exploit measures.

1 Like

This method is mostly just Client.

I would Recommend using RaycastParams/ Raycast to do this (it should prevent odd behavior).

Try out this code in LocalScript in StarterCharacterScripts, and let me know if that’s what you are wanting/ looking for.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local debounce = false

local uis = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and debounce == false then
		debounce = true

		local raycastParams = RaycastParams.new()
		raycastParams.FilterDescendantsInstances = {plr.Character}
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

		local raycastResult = game.Workspace:Raycast(hrp.Position, hrp.CFrame.LookVector * 35, raycastParams)

		if raycastResult then
			local hitPos = raycastResult.Position
			local info = TweenInfo.new(0.2)
			local DashGoal = Instance.new('Part')
			DashGoal.Parent = workspace
			DashGoal.Position = hitPos
			DashGoal.Transparency = 1
			DashGoal.Anchored = true
			DashGoal.CanCollide = false
			DashGoal.CastShadow = false

			hrp.Anchored = true
			local Dash = TweenService:Create(hrp, info, {CFrame = DashGoal.CFrame})
			Dash:Play()
			hrp.Anchored = false
			DashGoal:Destroy()
		else
			local info = TweenInfo.new(0.1)
			local DashGoal = Instance.new('Part')
			DashGoal.Parent = workspace
			local newCFrame = char.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(0, 0, -34))
			newCFrame = CFrame.lookAt(newCFrame.Position, char.PrimaryPart.Position)
			DashGoal.CFrame = newCFrame
			DashGoal.Transparency = 1
			DashGoal.Anchored = true
			DashGoal.CanCollide = false
			DashGoal.CastShadow = false

			hrp.Anchored = true
			local Dash = TweenService:Create(hrp, info, {CFrame = DashGoal.CFrame})
			Dash:Play()
			hrp.Anchored = false
			DashGoal:Destroy()
		end

		wait(0.5)

		debounce = false
	end
end)

hum.Died:Connect(function()
	local debounce = false
end)
1 Like

If the method above don’t help you. Surely this YT Tutorial will. Roblox Dash System Tutorial - YouTube

I already have the code made its just about how to handle it (like in the video you sent he used client → server → client) but I don’t know if that’s necessary.

His tutorials aren’t that always that great, it’s one of the main reasons I’m asking here. I’ve already watched that one before

oh, my bad. Had to think for a bit.

Not exactly sure how to go about this. I honestly thought this would be an easy solution, but I guess not.

Client = less lag
Maybe this Feedback can help you. Should a sprint and a roll be done by the server or client?

client - server - client is better for performance, and I don’t think it makes any difference in exploitability