I am trying to achieve a script where a part moves around another part (not within a loop, it’s a function that whenever called, slightly moves the part around the other part). For example, once it’s called, it’ll move slightly within a circle around the other part.
I’m, not sure exactly how to wrap it around the part. The issue is that I wanna make it move around the part in small steps, but I’m not quite sure where to go from here.
I’ve been looking around on DevForum for help and I’ve gotten no result.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local partA = workspace.PartA -- the part that moves
local partB = workspace.PartB -- the part that part a goes around
function circle()
partA.CFrame += Vector3.new(math.sin(0.3), 0, math.cos(0.3))
end
Any help would be much appreciated - I’ve been stuck on this for a while. Thank you for reading.
Edit: If there’s anything I’ve been obscure about - please let me know. I can detail further if needed.
local degree = 0
local function rotatePart()
local center = centerPart.CFrame
local angle = CFrame.Angles(0,math.rad(degree),0)
local offset = CFrame.new(0,0,100) -- where the part is from the center
local rotatedCFrame = center * angle * offset
part.Position = rotatedCFrame.Position
degree += 1
end
I think the problem is that you are waiting 2 seconds between each iteration. It is rotating, but very slowly. I would suggest increasing the degree by more than 1 or calling the function more frequently.
It seems almost completely perfect, it’s just the only problem is that it jumps to the other side of the part it’s moving around, is there any way to change this?
I dont think wait time is the problem anymore. It sounds like the axis is wrong. Just replace the math.rad(degree) into a different axis when creating the angle variable.