Okay so basically, i’m trying to make it to where if a player dashes to the left they’ll still be able to rotate the dash direction but i’m starting to get very confused on how linear velocity works. I’ve been using body velocity before and kept on running into an issue where when the player dashes it doesn’t really go into the direction they’re intended to go in and it almost feels like a barrier is like being placed in front of them. but now i’ve ran into another issue. When they dash to the left they go in a completely different direction instead of the one they’re supposed to go in the left.
local RP = game:GetService("ReplicatedStorage")
local Modules = RP.Modules
local Animations = RP.AnimationFolder
local ValueModule = require(Modules.ValueModule)
local Value = require(Modules.ValueCheck)
local module = {}
local WalkSpeed = 30
local JumpHeight = 7.2
local BodyVelocityForce = Vector3.new(math.huge, 0, math.huge)
local BVP = math.huge
local DashDuration = 0.4
local DashSpeed = 100
local DashENSpeed = 10
local gamesettings = UserSettings().GameSettings
local Camera = workspace.Camera
local function LeftDash(Character)
-- Player Stuff
local LeaderStats = game.Players:GetPlayerFromCharacter(Character):WaitForChild("leaderstats")
local CurrentCharacter = LeaderStats:WaitForChild("CurrentCharacter")
local HumanoidRootPart = Character.PrimaryPart
local Humanoid = Character:FindFirstChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
local Values = Character:WaitForChild("PlayerValues")
if Values:FindFirstChild("Dashing") or Values:FindFirstChild("DashCD") then return end
for i,v in pairs(HumanoidRootPart:GetChildren()) do
if v:IsA("BodyVelocity") or v:IsA("BodyMover") then
v:Destroy()
end
end
-- Velocity
local DirectionalForce = -1
local Increment = ((DashENSpeed- DashSpeed) / (DashDuration * 60)) * 2
local Velocity = Instance.new("LinearVelocity", HumanoidRootPart)
local Attachment0 = Instance.new("Attachment", HumanoidRootPart)
Velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
Velocity.MaxForce = math.huge
Velocity.Attachment0 = Attachment0
local Dashing = ValueModule:AddValue("Dashing", nil, Values)
Humanoid.WalkSpeed = 0
Humanoid.JumpHeight = 0
--Animation
local DashAnimation = Animator:LoadAnimation(Animations[CurrentCharacter.Value].DashAnimations.Left)
DashAnimation:AdjustSpeed(5)
DashAnimation:Play()
gamesettings.RotationType = Enum.RotationType.CameraRelative
for i = DashSpeed,DashENSpeed,Increment do
local MoveDirection = HumanoidRootPart.CFrame.RightVector
Velocity.VectorVelocity = Vector3.new(MoveDirection * i * DirectionalForce, 0, MoveDirection.Z * i * DirectionalForce)
wait()
end
Velocity:Destroy()
Attachment0:Destroy()
Humanoid.WalkSpeed = WalkSpeed
Humanoid.JumpHeight = JumpHeight
DashAnimation.Ended:Connect(function()
Dashing:Destroy()
ValueModule:AddValue("DashCD", 0.3, Values)
gamesettings.RotationType = Enum.RotationType.MovementRelative
end)
end
function module:Start(Character, DashType)
local Hum = Character:WaitForChild("Humanoid")
local Animator = Hum:WaitForChild("Animator")
local Hrp = Character:WaitForChild("HumanoidRootPart")
if DashType == "Left" then
LeftDash(Character)
--elseif DashType == "Right" then
-- RightDash(Character)
--elseif DashType == "Backward" then
-- BackwardDash(Character)
--elseif DashType == "Forward" then
-- ForwardDash(Character)
end
end
return module