This is a bit hard to explain but basically I’m trying to keep a fixed distance between two a center part, and another part orbiting it, so like a constant 5 block distance between each of the parts. Sorry if this explanation isn’t clear, here is a video and the script:
local rootpart = script.Parent:WaitForChild("HumanoidRootPart")
local workspacepart = workspace.part
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(1, 1, 1)
part.Anchored = true
part.CanCollide = false
part.Shape = "Ball"
part.Material = "SmoothPlastic"
game:GetService("RunService").Heartbeat:Connect(function()
part.Position = Vector3.new(-(rootpart.Position - workspacepart.Position).unit.X*5, workspacepart.Position.Y, -(rootpart.Position - workspace.part.Position).unit.Z*5)
end)
As you can see in the video, the outside part gets closer to the center part as I move near it, and gets further away from the center part as I move away from it. Also, here’s a copy of the place if you want to see it for yourself:
Test.rbxl (20.9 KB)
Thanks for your time!