I have a linear velocity constraint on the server moving the character in the wrong direction. It only happens after I use a dash move. In the video, I’ve already used the dash, the next time I activate the constraint it uses the wrong direction- except printing the properties shows its close to the right direction? The first time I punch moves in the wrong direction, the second time it move in the correct direction.
The strange thing is- the properties show that the properties at the time of the incorrect direction are similar to that of the correct direction? The incorrect direction seems to be locked to an axis.
Dash Properties (Happens before the error):
Error Properties (This moves in the incorrect direction?):
Second-Attempt Properties (This is the second punch that shows correct direction):
Constraint Function:
function Constraints.LinearVelocity:Start(
instance: BasePart,
timer: number?,
direction: Vector3,
force: number,
relativity: Enum.ActuatorRelativeTo?,
mode: Enum.VelocityConstraintMode?
): number
local timestamp = os.clock()
local humanoid = instance.Parent:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid then
local constraint = instance:FindFirstChild(prefix.."LinearVelocity") :: LinearVelocity
if not constraint then return 0 end
constraint.VelocityConstraintMode = mode or Enum.VelocityConstraintMode.Vector
constraint.RelativeTo = relativity or Enum.ActuatorRelativeTo.World
if direction ~= nil and force ~= nil then
if constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Vector then
constraint.VectorVelocity = direction.Unit * force
elseif constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Line then
constraint.LineDirection = direction.Unit
constraint.LineVelocity = force
elseif constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Plane then
constraint.PlaneVelocity = Vector2.new(direction.Unit.X, direction.Unit.Z) * force
end
if constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Line then
constraint.Attachment0.Axis = direction
else
constraint.Attachment0.Axis = Vector3.new(1, 0, 0)
end
end
if timer ~= 0 then
constraint.MaxForce = instance.AssemblyMass * maxForce * workspace.Gravity
constraint.Enabled = true
if game.Players:GetPlayerFromCharacter(instance.Parent) then
print("-----------------------\nLinear Velocity Properties: ")
print("Attachment0 Axis: ", constraint.Attachment0.Axis)
print("VelocityConstraintMode: ", constraint.VelocityConstraintMode)
print("RelativeTo: ", constraint.RelativeTo)
if constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Vector then
print("VectorVelocity: ", constraint.VectorVelocity)
elseif constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Line then
print("LineDirection: ", constraint.LineDirection)
print("LineVelocity: ", constraint.LineVelocity)
elseif constraint.VelocityConstraintMode == Enum.VelocityConstraintMode.Plane then
print("PlaneVelocity: ", constraint.PlaneVelocity)
end
end
Constraints.LinearVelocity.Timestamps[instance] = timestamp
if timer ~= nil and timer > 0 then
task.delay(timer, function()
if Constraints.LinearVelocity.Timestamps[instance] == timestamp then
Constraints.LinearVelocity:Stop(instance, timestamp)
end
end)
end
end
end
return timestamp
end
Drag Function (Calls Constraint Function):
function Mechanics.Drag(Attacker: Model, Victims: {Model}, Distance: number)
local averagePosition = Vector3.zero
local roots = {Attacker.PrimaryPart}
for i,Victim in Victims do
averagePosition = averagePosition + Victim.PrimaryPart.Position
table.insert(roots, Victim.PrimaryPart)
end
averagePosition = averagePosition / #Victims
local dragTime, dragRatio = .2, 1--4/5
local damagePosition = Attacker.PrimaryPart.Position
local direction = (averagePosition - Attacker.PrimaryPart.Position).Unit
direction = Vector3.new(direction.X, 0, direction.Z) * Distance
if true and (averagePosition - damagePosition).Magnitude > (Attacker.PrimaryPart.Size.Z * 4)
or true -- always
then
task.spawn(function()
Constraints.LinearVelocity:Start(Attacker.PrimaryPart, dragTime, direction, Distance, nil, Enum.VelocityConstraintMode.Line)
end)
end
for i,victim in pairs(Victims) do
task.spawn(function()
Constraints.LinearVelocity:Start(victim.PrimaryPart, dragTime, direction, Distance * dragRatio, nil, Enum.VelocityConstraintMode.Line)
end)
end
end





