Why does my LinearVelocity never go direction were the player is facing? Sometimes it’s offset a little bit sometimes it’s on track depending on were i’m looking on the map.
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humrp = char.HumanoidRootPart
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local debounce = false
local connect
local function ChangeBoost(direction, amount)
local Direction = direction
local currentspeed = char.Humanoid.WalkSpeed
char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed - currentspeed
local lv = Instance.new("LinearVelocity")
lv.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
lv.Attachment0 = humrp.RootAttachment
lv.ForceLimitsEnabled = true
lv.ForceLimitMode = Enum.ForceLimitMode.PerAxis
lv.MaxAxesForce = Vector3.new(1,0,1) * 10000
lv.VectorVelocity = Direction * amount
lv.RelativeTo = Enum.ActuatorRelativeTo.World
lv.Parent = humrp.RootAttachment
connect = RunService.Heartbeat:Connect(function()
lv.VectorVelocity = Direction * amount
end)
task.delay(0.5, function()
char.Humanoid.WalkSpeed = currentspeed
lv:Destroy()
connect:Disconnect()
end)
end
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Q and debounce == false then
ChangeBoost(humrp.CFrame.LookVector, 100)
end
end)