Here is the dash script:
local DASH_SPEED = 100
local DASH_FORCE_FACTOR = 3000
local DASH_TIME = 0.2
local humanoid = if char then char:FindFirstChildOfClass("Humanoid") else nil
local root = if humanoid then humanoid.RootPart else nil
if not root then
return
end
local clone = storage.CartCurt.DashTrail:Clone()
clone.Attachment0 = root:WaitForChild("Attachment0")
clone.Attachment1 = root:WaitForChild("Attachment1")
clone.Parent = root
task.spawn(function()
task.wait(.5)
clone.Enabled = false
debris:AddItem(clone, .5)
end)
local attachmentMaybe = root:FindFirstChild("DashAttachment")
if attachmentMaybe and not attachmentMaybe:IsA("Attachment") then
attachmentMaybe:Destroy()
attachmentMaybe = nil
end
local attachment = if attachmentMaybe then attachmentMaybe else Instance.new("Attachment")
attachment.Name = "DashAttachment"
attachment.Parent = root
local velocity = Instance.new("LinearVelocity")
velocity.Name = "DashVelocity"
velocity.Attachment0 = attachment :: Attachment
velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
velocity.MaxForce = DASH_FORCE_FACTOR * root.AssemblyMass
velocity.VectorVelocity = Vector3.new(0, 0, -DASH_SPEED)
velocity.Parent = root
debris:AddItem(velocity, DASH_TIME)
How it should be:
How is it now(It only happens if you jump right after dash):
How do i solve this?