How to rotate part in this loop?


I was wondering, how would I rotate this part in sync with the position loop? Here’s the script and an example of what I mean.

local center = workspace.Dummy.HumanoidRootPart
local Part = script.Parent

-- You may edit these variables
local ORBIT_TIME = 15
local RADIUS = 5
local ECLIPSE = 1 --50% as small radius on the short side, if 1 it's a perfect circle
local ROTATION = CFrame.Angles(0,0,0) --Rotate which direction to rotate around

-- But not these
local sin, cos = math.sin, math.cos
local ROTSPEED = math.pi*2/ORBIT_TIME

-- There are many ways to run this loop, you could do while true do if you want, if so use this: rot = rot + wait() * ROTSPEED 
local rot = 0
while true do
	rot = rot + wait() * ROTSPEED
	Part.CFrame = ROTATION **ECLIPSE, 0, cos(rot)*RADIUS) + center.Position

As you can see, the part is only changing position but not rotating towards the player. How do I make it rotate towards the player in sync?

1 Like

Use Cframe.Lookat(a,b) and done :slight_smile: