I’m making a dash script using LinearVelocity ON PURPOSE because I WILL NOT use BodyVelocity or other deprecated classes, but I can’t even get this class to work on the character just to test.
When I try to apply a LinearVelocity to any attachment on the character, regardless of the velocity or maxforce I input, all movement stops and my characters velocity is “paused” until the LinearVelocity constraint is destroyed.
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ContextActionService = game:GetService('ContextActionService')
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
local Animations = ReplicatedStorage['Client Animations']
local Anims = {
Humanoid:LoadAnimation(Animations["Dash Left"]),
Humanoid:LoadAnimation(Animations["Dash Backward"]),
Humanoid:LoadAnimation(Animations["Dash Right"]),
Humanoid:LoadAnimation(Animations["Dash Forward"]),
}
local DashRayParams = RaycastParams.new()
DashRayParams.FilterType = Enum.RaycastFilterType.Include
DashRayParams.FilterDescendantsInstances = {workspace.Terrain}
local LinearVelocityTemplate = Instance.new('LinearVelocity')
LinearVelocityTemplate.VelocityConstraintMode = Enum.VelocityConstraintMode.Plane
LinearVelocityTemplate.PrimaryTangentAxis = Vector3.new(1, 0, 0)
LinearVelocityTemplate.SecondaryTangentAxis = Vector3.new(0, 0, 1)
LinearVelocityTemplate.MaxForce = 900
LinearVelocityTemplate.Parent = script
local DashDuration = 1
local DashCooldown = 1.5
local DashMagnitude = 300
local LastDash = 0
local function FindAngleAnim()
local Animation, Closest = nil
local AngleZ = HumanoidRootPart.CFrame.LookVector:Dot(Humanoid.MoveDirection)
local AngleX = HumanoidRootPart.CFrame.RightVector:Dot(Humanoid.MoveDirection)
local DashAngle = math.atan2(AngleZ, AngleX)
for Index, Anim in pairs(Anims) do
local IndexAngle = (Index - 3) * (math.pi / 2)
local DiffAngle = math.abs((Index == 1 and -math.abs(DashAngle) or DashAngle) - IndexAngle)
if not Animation or DiffAngle < Closest then
Animation = Anim
Closest = DiffAngle
end
end
return Animation
end
local function ApplyDashForce(Duration: number, ForceAnim: AnimationTrack)
local Force = LinearVelocityTemplate:Clone()
local DashDirection = Humanoid.MoveDirection.Magnitude >= 0.01 and Humanoid.MoveDirection or -HumanoidRootPart.CFrame.LookVector
Force.PlaneVelocity = Vector2.new(DashDirection.X * DashMagnitude, DashDirection.Z * DashMagnitude)
Force.Attachment0 = _G.Chakra.Plexus -- Attachment at center of Torso, verified alr
Force.Parent = HumanoidRootPart
local AnimationTrack = ForceAnim or FindAngleAnim()
AnimationTrack:GetMarkerReachedSignal('Pause'):Connect(function()
AnimationTrack:AdjustSpeed(0)
end)
AnimationTrack:Play()
task.delay(Duration, function()
Force:Destroy()
AnimationTrack:AdjustSpeed(1)
end)
end
ContextActionService:BindAction('Dash', function(Action, State, Input)
if not Humanoid then return end
if Action ~= 'Dash' then return end
if State ~= Enum.UserInputState.Begin then return end
if os.clock() - LastDash < DashCooldown + DashDuration then return end
LastDash = os.clock()
ApplyDashForce(DashDuration, Humanoid.MoveDirection.Magnitude < 0.01 and Anims[2] or nil)
end, true, Enum.KeyCode.Q, Enum.KeyCode.ButtonB)
I tried copying and pasting the LinearVelocity the ApplyDashForce function creates into a dummy rig and THAT worked??? Someone please help me…