:Clone() Not working even with setting parent!

Hello! I am writing a simple star system generator. All was working well until I tried to put the orbiting script onto the planets. It works once but it does not clone the orbit script!

Here is my code:

local atrribute = game.Workspace.CreationPropertiesHandlers.PlanetCreationHandler

local Colour = atrribute:GetAttribute("Colour")
local Size = atrribute:GetAttribute("Size")
local HasAtmosphere = atrribute:GetAttribute("HasAtmosphere")
local OrbitRadius = atrribute:GetAttribute("OrbitRadius")
local OrbitSpeed = atrribute:GetAttribute("OrbitSpeed")
local Planets = atrribute:GetAttribute("Planets")

for i = 1, Planets do
	Part = Instance.new("Part")
	Part.Parent = workspace
	Part.Name = "Planet" .. i
	Part.Anchored = true
	game.ServerStorage.OrbitScript:Clone()
	game.ServerStorage.OrbitScript.Parent = Part
	atrribute:SetAttribute("OrbitRadius", OrbitRadius * i)
	atrribute:SetAttribute("OrbitSpeed", OrbitSpeed * i)
	Part.Material = "Neon"
	Part.Size = Vector3.new(Size, Size, Size)
	Part.Shape = "Ball"
	Part.BrickColor = BrickColor.new(Colour)

	wait()
end

I have no clue what I am doing wrong so if anyone knows what, it will be appreciated.
Thanks
Tangy

Have you checked if OrbitScript.Archivable is true?

1 Like

image
Yep just did that now.
It was already archivable

Do you see any errors in your output?
Also is Planets an integer or what?

1 Like

This should be

local x = game.ServerStorage.OrbitScript:Clone()
x.Parent = Part
2 Likes

image
This is the error

Planets is an integer yes

Use WaitForChild, the script may have loaded before the Instance did

1 Like

You can do a script like this:
local planetsCreated = 0
while true do:
if planetsCreated < Planets:
#Create your part

Edit: Also you need to add a wait so it will not give an error saying exhaustion

1 Like