How would I make a part revolve around another?

Earlier today, I saw this post in a topic by Imaginze. I’m just wondering how we can make a part revolve around another in increments of 90 degrees using the mouse. I tried to attempt this in the past by getting the mouse position’s cosine, and I even attempted to use the mouse position’s arc cosine, but none of that seemed to have worked. Can anyone give me an insight of how this would work?

I’m confused; you said to make a part revolve around another part, yet when I opened the link, I didn’t see how that was related to your question. I’m assuming that your question is actually not related to revolution but rather to snap the part’s rotation every 90 degrees.

I wasn’t talking about the post, and that was not my question. I want to know how we can make a part revolve around another part according to the mouse’s position, somewhat like the Earth revolving around the sun, but in increments of 90 degrees.

If that’s all you want, then it’s very simple. There are also instances such as “LineForce” that allows you to have similar result.

I attempted a similar thing, but you didn’t answer this part of the question

This is why I assumed that your question was related to rotation snapping. Like I said, I’m confused about what your main goal really is; be more specific, or at least show some examples.

How would I even know exactly what you are even talking about, “make a part revolve around another part according to the mouse’s position in increments of 90 degrees.” How does that even make sense according to mouse position in increments of 90 degrees? Every time the mouse moves, does it increase by 90 degrees? Does it depend on where the player is looking as well?

I created this code:

local part = script.Parent.part
local base = script.Parent.base

local rot = 0
while true do
	local stepTime = game:GetService("RunService").Heartbeat:Wait()
	rot+=math.rad(stepTime*720)
	local p1 = math.cos(rot)
	local p2 = math.sin(rot)
	
	local look,right = base.CFrame.LookVector,base.CFrame.RightVector
	
	local x = ((look*p1)+(right*p2))*10
	
	part.CFrame = base.CFrame*CFrame.new(x)
end

Since you stated that you attempted to get the cosine of the mouse it might be possible to implement that here.

What you are asking for makes no sense. Like @MakerDoe said, making a part revolve around a part is quite simple, just use a LineForce, use the code LineForce.Magnitude = Part:GetMass()*workspace.Gravity if there is gravity, and if not, remove the *workspace.Gravity, and then set the AssemblyLinearVelocity to something suitable to get it to revolve.

However, in increments of 90 degrees according to the mouse’s position makes no sense. To make something revolve around a part in 90 degree increments, I believe you’d use attachments for that to set a center of rotation for the object. According to the mouse’s position, though, is where it doesn’t make sense.

I’m assuming by “according to the mouse’s position” you mean that you can move your mouse around to get it to revolve. Am I correct?

I fixed the issue days ago by using attachments and mathematics was not required for it.