I’m currently working on a 2D Platformer and I’m trying to allow the player to dash toward the mouse cursor. Does anyone have any ideas? Any help is appreciated
What I’ve currently got:
local Debris = game:GetService('Debris')
local UIS = game:GetService('UserInputService')
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character
local HRP = Character:WaitForChild("HumanoidRootPart")
local Cooldown = false
UIS.InputBegan:Connect(function(Input, GameProccessed)
if not GameProccessed and UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and Cooldown == false then
Cooldown = true
local Bv = Instance.new("BodyVelocity")
Bv.Parent = Character.UpperTorso
Bv.P = 1250
Bv.MaxForce = Vector3.new(math.huge,math.huge, 0)
Bv.Velocity = Character.UpperTorso.CFrame.lookVector*50
Debris:AddItem(Bv, 0.2)
task.wait(2)
Cooldown = false
end
end)
Simply just launches the player towards the direction that the UpperTorso is facing.