I’m attempting to make a Power Up that spins on the ground. I am using Motor 6Ds to achieve this. The Power Up spins normally, until at a point when it just starts spazzing out for a few seconds, and then it will start spinning normally again. View the following recording:
By no means do I actually understand how Motor 6Ds work, I’m just trying to learn how to use them. Here is the code that I use:
local motor = Instance.new("Motor6D", model.PrimaryPart)
motor.Part0 = model.PrimaryPart
motor.Part1 = model:FindFirstChild("Container")
-- (unrelated filler)
self.spinConnection = RunService.Stepped:Connect(function() -- i used AI to generate this code :sob: im just trying to get it to work
local position = motor.C1.Position
local y = (tick() * SPIN_SPEED) % (2 * math.pi) -- spin speed is 0.5 in the video
local _, _, z = motor.C1.Rotation:ToEulerAnglesXYZ()
motor.C1 = CFrame.new(position) * CFrame.Angles(self.info.Tilt, y, z) -- tilt is math.rad(15) for the current Power Up
end)
If it should be useful, the way I organize the Power Ups is like so:
- A hitbox part (C0) with CanCollide set to true that acts as the collider for the Power Up (I have it set so it doesn’t collide with players via Collision groups.
- A container part (C1, which is literally a 0.001 xyz stud cube) that acts as the part that spins, all of the decorative parts are welded to this part, following the container.