I need to transfer my Dashing Script from World Space to Local Space

All right, so my Dashing Script works fine, it dashes forwards, and then deletes the body velocity after a certain amount of time has passed. The issue is that it always utilizes the World Z-Axis, rather than the local Z-Axis of the Player. How could I utilize C-Frames to do this? Can anyone help?

Flawed World Space Dash

I’ve checked out a few YouTube videos, and the C-Frame Wiki, but I’m not quite understanding properly.

Server Script

-- Variables --
local Remote = game.ReplicatedStorage.HpDash
local Activated = false

-- Settings --
local DashSpeed = 25
local DashLength = .5

-- Script --

Remote.OnServerEvent:Connect(function(Player)

	if Activated == false then
		local Char = Player.Character
		print ("You've reached the server.")
			Activated = true


			local Limbs = Char:GetChildren()
			print (Limbs)

				for i, v in pairs(Limbs) do 
					if v:IsA("MeshPart") or v:IsA("Part") then
					v.Massless = true
					end
				end

			local Dash = Instance.new("BodyVelocity")
				Dash.MaxForce = Vector3.new(10000,10000,10000)
				Dash.Parent = Char.HumanoidRootPart
				Dash.Velocity = Vector3.new(0,0,-DashSpeed)
				Dash.P = 3

			wait (DashLength)
			Dash:Destroy()
			Activated = false
	else end
end)

Local Script

-- Variables -- 

local UserInputService = game:GetService("UserInputService")
local Remote = game.ReplicatedStorage.HpDash

-- Settings --
local Activated = false


-- Script --

UserInputService.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed == false then

	if input.KeyCode == Enum.KeyCode.Q and UserInputService:IsKeyDown(Enum.KeyCode.W) and Activated == false then
		Activated = true
		print ("You've fired to the server that you're performing a frontal dash!")
		Remote:FireServer()
		wait (0.6)
		Activated = false
	end

else end
end)

If anyone can help me understand this, I would really appreciate it! I have a feeling I’ll be needing to know how to do this for a lot of things. :sweat_smile: :pray:

If anyone knows any videos where I could learn how to do this properly or resources, that’s good too

1 Like