I’ve been trying to figure this out for awhile. The goal is to make a simple dash that sends the player forward. The current script uses LinearVelocity - see code at bottom. I have three problems, I will list them here. I have already tried to disable all other external scripts that might affect it - they do not.
If you have a solution, my goal is to understand coding instead of just copy and pasting solutions, ESPECIALLY simply inserting a tutorial model.
Video (Youtube)
-
Player does not move unless midair
The intended function is for the player to move in a straight line linearly (no up or down movement) for some seconds.
The player does not move at all unless they are midair, usually as a result of jumping. I have tried to add a slight upwards force to theLinearVelocity
(MaxAxesForce
adjusted accordingly), but that made the player go significantly further if they triggered the action while jumping upwards, and if in freefall, completely plummeting them to the ground with even less movement. This also applies to forcing the player to jump. Additionally, I tried to use BodyVelocity, but that didn’t work either. I tried setting thePlatformStand
property of the humanoid to true, but that just causes the player to get flung. Lastly, I tried usingHumanoidRootPart:ApplyImpluse()
but that did nothing but freeze the player midair (with a vector3 inside of course). -
The velocity shifts the player a little bit right or left if the rootpart’s lookvector isn’t roughly 90 or 45 degrees (and their multiples).
This one is hard to explain and honestly I have no idea how to approach this - it also applies to when I raycast with lookvectors from the camera. Watch the video, this is demonstrated on the last attempt.
UserInputService.MouseBehavior = 1
andUserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative
, by the way. -
Velocity doesn’t apply instantly
The intended function is for the velocity to instantly apply and not gradually accelerate. I tried to set an extremely high velocity for a short amount of time, but it still needed the same time to accelerate to full speed as lower velocities.
This is where I thoughtApplyImpulse
would work, but it didn’t. This is the code I roughly tried:HumanoidRootPart:ApplyImpulse(HumanoidRootPart.CFrame.LookVector * 200)
, which only froze the player midair. If this is the solution, PLEASE tell me how to use this function properly.
local function utility(plr)
rollutilityanim:Play()
local hum = plr.Character.Humanoid
local rootpart = plr.Character.HumanoidRootPart
local att = Instance.new("Attachment", rootpart)
local lv = Instance.new("LinearVelocity", plr.Character)
local lookvect = rootpart.CFrame.LookVector
lv.Attachment0 = att
lv.ForceLimitMode = Enum.ForceLimitMode.PerAxis
lv.MaxAxesForce = Vector3.new(5000,0,5000)
Debris:AddItem(lv, 0.7)
Debris:AddItem(att, 0.7)
lv.VectorVelocity = lookvect*hum.WalkSpeed * 8
task.delay(0.5, function()
lv.VectorVelocity = lookvect*hum.WalkSpeed * 3
end)
end