I’m having a problem with limiting a BodyGyro from rotating the X and Y axes of a part. I want the part to be able to rotate on the Z axis so that when a player steps on the part, the part will only rotate on the Z axis but not on any other axis. This will be done using a BodyPosition and a BodyGyro, but it seems to not be working.
This is what the function for creating the BodyMovers for the Part looks like:
local function PhysicsAnchoredPart(Part)
local Position = Instance.new("BodyPosition", Part);
Position.MaxForce = Vector3.new(1, 1, 1) * math.huge;
Position.Position = Part.Position;
local BodyGyro = Instance.new("BodyGyro", Part);
BodyGyro.MaxTorque = Vector3.new(
Part:FindFirstChild("LockY") and math.huge or 0,
Part:FindFirstChild("LockX") and math.huge or 0,
Part:FindFirstChild("LockZ") and math.huge or 0
);
BodyGyro.CFrame = CFrame.new(Part.Position, Part.Position + Part.CFrame.LookVector);
Part.Anchored = false;
end
This is what the part looks like in game:
There is another method of doing this using a hinge, but I’m not sure why this method doesn’t work? The part has IntValues named “LockY” and “LockX”, and the part also is oriented in a way where rotation in the Z axis should not change its LookVector. Why does it start moving frantically like that when there is a force applied to it by a character?