Dash system works fine, but whenever I die it only makes me dash forward?

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!
    Make dash direction consistent
  2. What is the issue? Include screenshots / videos if possible!
    Whenever I die, script makes me dash forward only
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find any solutions
local MD = 50

local player = game.Players.LocalPlayer
local character = script.Parent

local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local TS = game:GetService("TweenService")

local remote = game.ReplicatedStorage.Miscs.Dash.DashRemote
local fx = game.ReplicatedStorage.Miscs.Dash.Fx
local animations = game.ReplicatedStorage.Miscs.Dash.Animations

local slock = false

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = {game.Workspace:FindFirstChild("Baseplate")}



local debounce = false

uis:GetPropertyChangedSignal("MouseBehavior"):Connect(function()
	if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
		slock = true
	else
		slock = false		
	end
end)



uis.InputBegan:Connect(function(input,gpe)
	if gpe then return end
	
	if input.KeyCode == Enum.KeyCode.LeftShift and not debounce then
		debounce = true
		local anim = animations:WaitForChild("Animation")
		
		local VMdash = game.ReplicatedStorage.Modules.ViewmodelHandler.Value
		
		local v = Instance.new("BodyVelocity", character.HumanoidRootPart)
		v.MaxForce = Vector3.new(999999,0,999999)
		
		VMdash.Value = false
		
		character:FindFirstChild("Humanoid"):LoadAnimation(anim):Play()
		
		script.Sound:Play()
		
		TS:Create(player.PlayerGui.Vignette.Dash, TweenInfo.new(.05, Enum.EasingStyle.Exponential), {ImageTransparency = 0}):Play()
		TS:Create(player.PlayerGui.InfoUI.Dash.Frame, TweenInfo.new(.05, Enum.EasingStyle.Exponential), {Size = UDim2.new(0.004, 0,0.302, 0)}):Play()
		
		---//Keybinds//---
		
		if uis:IsKeyDown(Enum.KeyCode.W) and uis:IsKeyDown(Enum.KeyCode.A) and slock then
			v.Velocity = character.Humanoid.MoveDirection * MD
		elseif uis:IsKeyDown(Enum.KeyCode.W) and uis:IsKeyDown(Enum.KeyCode.D) and slock then
			v.Velocity = character.Humanoid.MoveDirection * MD
		elseif uis:IsKeyDown(Enum.KeyCode.S) and uis:IsKeyDown(Enum.KeyCode.A) and slock then
			v.Velocity = character.Humanoid.MoveDirection * MD
		elseif uis:IsKeyDown(Enum.KeyCode.S) and uis:IsKeyDown(Enum.KeyCode.D) and slock then
			v.Velocity = character.Humanoid.MoveDirection * MD	
		elseif uis:IsKeyDown(Enum.KeyCode.W) or character.Humanoid.MoveDirection.Magnitude == 0 then
			if slock then
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector * MD		
			else
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector * MD		
			end
		elseif uis:IsKeyDown(Enum.KeyCode.A) then
			if slock then
				v.Velocity = character.HumanoidRootPart.CFrame.RightVector * -MD	
			else
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector * MD	
			end
		elseif uis:IsKeyDown(Enum.KeyCode.S) then
			if slock then
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector * -MD	
			else
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector* MD	
			end
		elseif uis:IsKeyDown(Enum.KeyCode.D) then
			if slock then
				v.Velocity = character.HumanoidRootPart.CFrame.RightVector * MD
			else
				v.Velocity = character.HumanoidRootPart.CFrame.LookVector * MD	
			end
		end

		game.Debris:AddItem(v, .1)
		
		wait(.4)
		
		VMdash.Value = true
		
		TS:Create(player.PlayerGui.Vignette.Dash, TweenInfo.new(.4, Enum.EasingStyle.Circular), {ImageTransparency = 1}):Play()
	
		TS:Create(player.PlayerGui.InfoUI.Dash.Frame, TweenInfo.new(1, Enum.EasingStyle.Exponential), {Size = UDim2.new(0.797, 0,0.302, 0)}):Play()
		
		task.wait(1)
		
		remote:FireServer(character, v.Velocity)
		
		debounce = false
		
		script["button.wav"]:Play()

		TS:Create(player.PlayerGui.InfoUI.Dash.Frame, TweenInfo.new(.01, Enum.EasingStyle.Exponential), {BackgroundColor3 = Color3.new(1, 1, 1)}):Play()
		TS:Create(player.PlayerGui.InfoUI.Dash.Man, TweenInfo.new(.01, Enum.EasingStyle.Exponential), {ImageColor3 = Color3.new(1, 1, 1)}):Play()
		
		wait(.01)
		
		TS:Create(player.PlayerGui.InfoUI.Dash.Frame, TweenInfo.new(3, Enum.EasingStyle.Circular), {BackgroundColor3 = Color3.new(0, 242, 255)}):Play()
		TS:Create(player.PlayerGui.InfoUI.Dash.Man, TweenInfo.new(3, Enum.EasingStyle.Exponential), {ImageColor3 = Color3.new(0, 242, 255)}):Play()
	end
end)


remote.OnClientEvent:Connect(function(data)
	if data.Action == "Dash" then
		local hrp = data.Character.HumanoidRootPart
		for i = 1, 20 do
			for i = 1, math.random(1,3) do
				local windeffect = fx.Sphere:Clone()
				windeffect.Parent = workspace.Fx
				windeffect.Anchored = true
				windeffect.CanCollide = false
				windeffect.Transparency = 0
				windeffect.Name = "hb"
				windeffect.Material = Enum.Material.Neon
				windeffect.CanQuery = false
				windeffect.Size = Vector3.new(.07, .07, math.random(4,6))
				local colorRand = math.random(1,3)
				if colorRand == 1 then
					windeffect.Color = Color3.fromRGB(0,0,0)
				else
					windeffect.Color = Color3.fromRGB(180,180,180)		
				end
				windeffect.CFrame = CFrame.new(hrp.Position, hrp.Position + data.Direction) * CFrame.new(math.random(-25,25)/10,math.random(-4,2), math.random(-2, 2))
				game.Debris:AddItem(windeffect,.4)
				ts:Create(windeffect, TweenInfo.new(.4), {Transparency = 1, Size = Vector3.zero, CFrame = windeffect.CFrame * CFrame.new(0,0,math.random(2,4))}):Play()
			end
			local ray = workspace:Raycast(hrp.Position, Vector3.new(0,-4,0), params)
			if ray then
				local dust = fx.Dust:Clone()
				dust.Parent = workspace.Fx
				dust.CFrame = hrp.CFrame
				dust.Position = ray.Position
				dust.Attachment.Dust.Color = ColorSequence.new{ColorSequenceKeypoint.new(0,ray.Instance.Color), ColorSequenceKeypoint.new(1, ray.Instance.Color)}
				dust.Attachment.Dust:Emit(10)
				game.Debris:AddItem(dust,2)
			end
			task.wait()
		end
	end
end)

1 Like

Here’s a tip, instead of checking they’re on shiftlock or not, just use the cframe from the currentcamera, It’s easier, and cleaner.

1 Like

sorry for replying late, but how would I do that?

1 Like

game.workspace.Camera.CFrame.LookVector

1 Like