Hello, I wanted to ask for help with a question I have, I wanted to know how to make a dash system that will relocate the player’s cframe towards the mouse.Hit with a range limit.
I don’t know exactly where to start, I tried to get the Mouse.Hit but when I do a BodyPosition it goes exactly where the mouse is, and what I want is for it to just move a little facing the mouse location.
I’m not asking for a script, I’m asking for an explanation of how to do this to use more often. help me please.
What I need is to know how to make the Character give a short dash towards the mouse, if you know how please explain it to me please, in this case using BodyPosition and not BodyVelocity (if there’s a way) , in this case it would be what I would put in the BodyPosition.Position , I’m missing this part
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local userInput = game:GetService("UserInputService")
local debounce = false
userInput.InputBegan:Connect(function(key, processed)
if processed then return end
if debounce then return end
if key.KeyCode == Enum.KeyCode.E then
debounce = true
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = ((mouse.Hit.Position - hrp.Position).Unit * 50) * Vector3.new(1, 0, 1)
hrp.CFrame = CFrame.lookAt(hrp.Position, mouse.Hit.Position)
bodyVelocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
bodyVelocity.Parent = hrp
task.delay(0.25, function()
bodyVelocity:Destroy()
end)
task.wait(1)
debounce = false
end
end)
Is this satisfactory? Press the E key to trigger the dash. Feel free to play around with the script till it meets your desires.