Hey, I’m having trouble with a dash where it is aimed with the mouse. Holding Q puts you in place where you can turn to aim your dash, and releasing Q is supposed to launch the character in the direction they are facing. However, I’m having some weird issues with the launch; here is a video
//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/5X/5/d/2/f/5d2f87b2686590668b8ee9aa027e688c1afe962d.mp4
This is my code as well:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local RS = game:GetService("RunService")
local gravity = Vector3.new(0,game.Workspace.Gravity,0)
local vectorForce = script.VectorForce
local alignOrientation = script.AlignOrientation
local HRP = character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
local connection = nil
local boostForce = script.BoostVelocity
vectorForce.Attachment0 = HRP.RootAttachment
boostForce.Attachment0 = HRP.RootAttachment
local mouse_pos
UIS.InputBegan:Connect(function(input, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode.Q then
if connection == nil then
vectorForce.Enabled = true
vectorForce.Force = HRP.CFrame.lookVector*.01
alignOrientation.Enabled = true
humanoid:ChangeState("Physics")
HRP.Anchored = true
connection = RS.Heartbeat:Connect(function()
mouse_pos = mouse.Hit.Position
local look_vect = Vector3.new(mouse_pos.X, mouse_pos.Y, mouse_pos.Z)
HRP.CFrame = CFrame.lookAt(HRP.Position, look_vect) * CFrame.fromOrientation(-math.pi / 2, 0, 0)
end)
end
end
end)
UIS.InputEnded:Connect(function(input, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode.Q then
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(mouse_pos.X, mouse_pos.Y, mouse_pos.Z)) * CFrame.fromOrientation(-math.pi / 2, 0, 0)
connection:Disconnect()
connection = nil
HRP.Anchored = false
boostForce.Enabled = true
mouse_pos = mouse.Hit.Position
boostForce.VectorVelocity = Vector3.new(mouse.hit.p - HRP.Position).Unit * Vector3.new(100,100,100)
end
end)
Please help!