-
I want to achieve a dash system which is used simply to dash, Forward, Backward, Left and Right
-
I thought everything was working good until I realized it goes wrong when I dont use shift-lock
Using Shift-Lock everything works good since it goes to the right left front etc of the player.
Without using shiftlock the axis works but I dont want it to be like that. I want it to still dash left or right even if the character is facing that way. Here is The Problem I have :
as you can see the dash torwards the left goes backwards because the left isnt the same since the character is rotated. I would like to know how to fix this. Thank you very much.
I have tried using MoveDirection but I am not familiar with it and was unsuccessful.
Here is the script :
dashRemote.OnServerEvent:Connect(function(plr, key)
print(plr.Name.." is dashing")
print(key)
local char = plr.Character or plr.CharacterAdded:Wait()
local humr = char.HumanoidRootPart
local BP = Instance.new("BodyPosition")
BP.Parent = humr
BP.MaxForce = Vector3.new(1000000,1000000,1000000)
if key == "W" then
BP.Position = (humr.CFrame * CFrame.new(0,0,-60)).Position
elseif key == "A" then
BP.Position = (humr.CFrame * CFrame.new(-60,0,0)).Position
elseif key == "S" then
BP.Position = (humr.CFrame * CFrame.new(0,0,60)).Position
elseif key == "D" then
BP.Position = (humr.CFrame * CFrame.new(60,0,0)).Position
end
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://8000617431"
local dashAnim = char.Humanoid:LoadAnimation(anim)
dashAnim:Play()
wait(0.1)
BP:Destroy()
wait(0.2)
dashAnim:Stop()
anim:Destroy()
end)