Unanchored Orbit?

Okay I noticed a few things, I forgot the time and the Anchored statement. Here, it works now… You can set it up in a loop

local tweenn
local function tween(Part,Prop,Val,timing,TweenType) 
	local TweenService = game:GetService("TweenService")
	local goal = {}
	goal[Prop] = Val
	if timing then
		local tweenInfo
		if TweenType then
			tweenInfo = TweenInfo.new(timing,Enum.EasingStyle[TweenType])
		else
			tweenInfo = TweenInfo.new(timing)
		end
		tweenn = TweenService:Create(Part, tweenInfo, goal)
	else
		local tweenInfo = TweenInfo.new(5)
		tweenn = TweenService:Create(Part, tweenInfo, goal)
	end
	return tweenn:Play()
end


local DistanceAway = 100 -- distance before being unable to suck stuff...
local TowardsPart = workspace.AnchoredPart -- part that gets all the sucked unanchored objects
local folderOfObjects = workspace -- in case you want a certain folder with the unanchored objects..

local function SuckObjects()
	for _, v in pairs(folderOfObjects:GetChildren()) do
		if v:IsA("BasePart") then
			if v.Anchored == false then
				if (v.Position-TowardsPart.Position).Magnitude < DistanceAway then
					tween(v,"Position",TowardsPart.Position,5,"Quad")
				else
					print((v.Position-TowardsPart.Position).Magnitude)
				end
			end
		end
	end
end
SuckObjects()
1 Like