I’m trying to make a part float perfectly still using AssemblyLinearVelocity. Yes, I know it’s not ideal and there are things like LineForce, LinearVelocity, old bodymovers etc, however I would like to specifically do this using AssemblyLinearVelocity. I know it’s weird, but I need it that way.
The problem I’m having is that the part seems to always float downwards even when I set the velocity to 0. Here’s the code I’m using right now:
local Part = workspace:WaitForChild("Part")
game:GetService("RunService").Stepped:Connect(function()
Part.AssemblyLinearVelocity = Vector3.new(0,0,0)
end)
Here’s a video of the issue:
So far, I’ve tried using the old deprecated Part.Velocity, and I’ve tried setting the part mass to Massless, and it still floats downwards. It also doesn’t change if I use Heartbeat or RenderStepped. I don’t want to use constraints, so I’m stuck here.
I could, but for this specifically I want to use velocity since I need the part to move around. I simply just want the part not to be affected by gravity (which yes, I know there’s constraints, but I don’t want to use them in this case). I want to use velocity specifically, but I can’t make the part stay still.
local Part = workspace.Part
local Att = Instance.new("Attachment", Part)
local VF = Instance.new("VectorForce")
VF.Force = Vector3.new(0, Part:GetMass() * workspace.Gravity, 0)
VF.Attachment0 = Att
VF.Parent = Part
Edit: If you want this code to work on a model, use this instead.
local Model = workspace.Model
for _, Part:BasePart? in Model:GetDescendants() do
if Part:IsA("BasePart") then
local Att = Instance.new("Attachment", Part)
local VF = Instance.new("VectorForce")
VF.Force = Vector3.new(0, Part:GetMass() * workspace.Gravity, 0)
VF.Attachment0 = Att
VF.Parent = Part
end
end
This all works but is it possible to do this without VectorForce? I tried just putting Mass * Gravity for the part’s Y velocity and it still doesn’t stay perfectly still.