How to make it so that the player is automatically moving forward after a click

What I want to achieve: I want to achieve a spindash from sonic type move where the players speed is increased, the player is moving forward for a few seconds (without the actions of the player), and if you move the camera, the player will still move forward like how it would if you were pressing the W key and moving your camera at the same time

My issue: I don’t know what I have to put in my script. I looked at Humanoid.Jump and thought, “If there’s a Humanoid.Jump, then there has to be something called a Humanoid.Run!”. I had no luck finding what I need, so I assumed that it didn’t exist

Solutions I’ve tried so far: I tried to get the script to work if the humanoid is in a running state, but I quickly learned that the state of the humanoid and the movement of the humanoid were two different things (script didn’t work)

if there IS something that is called a Humanoid.Run or something similar, please tell me!

1 Like

Use Humanoid:Move(). This will allow you to move the player in a direction using a Vector3.

You may also want to temporarily change the movement speed of the player as well.

6 Likes

–coded by Shifty
local UIS = game:GetService(‘UserInputService’)–vars
local Player = game.Players.LocalPlayer
local Character = Player.Character
local HRP = Character:WaitForChild(“HumanoidRootPart”)
stoprev = true
speednum = 150
–functions
function keepgoing()
while true do
wait(0.01)
stoprev = false
HRP.SonicDash.Velocity = HRP.CFrame.LookVectorspeednum
if stoprev == true then
HRP.SonicDash:Destroy()
break
end
end
end
–inputs
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local Sonic = Instance.new(“BodyVelocity”, HRP)
Sonic.Name = “SonicDash”
Sonic.MaxForce = Vector3.new(math.huge, 0, math.huge)
Sonic.P = 5000
Sonic.Velocity = HRP.CFrame.LookVector
speednum
keepgoing()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
stoprev = true
end
end)

4 Likes

this is the improved version as your quotation mark and double dash are broken, and overall error in the script:

--coded by Shifty
local UIS = game:GetService("UserInputService") --vars
local Player = game.Players.LocalPlayer
local Character = Player.Character
local HRP = Character:WaitForChild("HumanoidRootPart")
stoprev = true
speednum = 10 -- closest to the player normal speed, you can set the speed to whatever you want
--functions
function keepgoing()
while true do
wait(0.01)
stoprev = false
HRP.SonicDash.Velocity = HRP.CFrame.LookVector * speednum
if stoprev == true then
HRP.SonicDash:Destroy()
break
end
end
end
–inputs
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
local Sonic = Instance.new("BodyVelocity", HRP)
Sonic.Name = "SonicDash" -- you can change the name
Sonic.MaxForce = Vector3.new(math.huge, 0, math.huge)
Sonic.P = 5000
Sonic.Velocity = HRP.CFrame.LookVector * speednum
keepgoing()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
stoprev = true
end
end)
1 Like