how do i prevent a part from moving with two conditions:
-
not anchored
-
NO deprecated instances
how do i prevent a part from moving with two conditions:
not anchored
NO deprecated instances
Not sure why wouldnt you want to have it anchored, as it is the most right way to do what you wanna do, but anyway
local startPos = part.Position
while task.wait() do
part.Position = startPos
end
or to be easier on performance
local startPos = part.Position
part:GetPropertyChangedSignal("Position"):Connect(function()
part.Position = startPos
end)
Script based approach may work as @Denz_Noviembre said. Here’s a physics based approach:
local workspace = game:GetService("Workspace");
local part = script.Parent;
local force = part.VectorForce;
local function updateForce()
force.Force = Vector3.new(0, workspace.Gravity * part:GetMass(), 0);
end
workspace:GetPropertyChangedSignal("Gravity"):Connect(updateForce);
updateForce();
Explorer:
This is equivalent to putting an object in space with no gravity. Imagine you hit the object downwards or any direction. The object would just go in that direction… continously, unless it hit something.
Pretty much, yes. Basically I’m cancelling out the weight of the part (W = mg). You can go more in depth and look for position changes and apply a cancelling force but it’s too much work imo.
i need to detect touch with an anchored item
Pretty sure that the :Touched() event still fires for anchored parts…