How to generate a Sphere out of Blocks (1,1,1)

Hey there,

I’m trying to figure out how to generate a sphere out of single Block parts. The size is e.g. 1,1,1.

I found this post and modified it to summon block parts but it is not exactly what I’m trying to achive.

I need a script which generates a spheric like planet out of blocks but it also needs to be filled with them. I tried to find posts or tutorials but never found one.
Can someone may help?

Thank you

1 Like

Have you seen this post?

1 Like

thank you so much never saw it !

Here is a function to do this for you it’s probably lighter than a module anyway.

function sphereFromPart(centerPos,radius,parent)
	local basePart = Instance.new("Part")
	basePart.Size = Vector3.new(1,1,1)
	basePart.Anchored = true
	basePart.Parent = parent
	for x = 1, radius*2 do
		for y = 1, radius*2 do
			for z = 1, radius*2 do
				local worldSpace = Vector3.new(-x+centerPos.X,-y+centerPos.Y,-z+centerPos.Z)
				if Vector3.new(x-radius,y-radius,z-radius).Magnitude <= radius then
					local new = basePart:Clone()
					new.CastShadow = false
					new.Parent = parent
					new.Position = worldSpace
				end
			end
		end
	end
end

--example
sphereFromPart(Vector3.new(0,100,0),20,game.workspace)

This will be a solid sphere.

3 Likes

Thank you this looks nice!!!

Thanks I actually updated it so that the position you supply would be the actual center of the sphere and you get a folder that contains all the parts so you don’t get flooded!


function sphereFromPart(centerPos,radius,parent)
	local sphereFolder = Instance.new("Folder")
	sphereFolder.Name = "Sphere"
	sphereFolder.Parent = parent
	local basePart = Instance.new("Part")
	basePart.Size = Vector3.new(1,1,1)
	basePart.Anchored = true
	for x = 1, radius*2 do
		for y = 1, radius*2 do
			for z = 1, radius*2 do
				local worldSpace = Vector3.new(centerPos.X+(x-radius),centerPos.Y+(y-radius),centerPos.Z-(z-radius))
				if Vector3.new(x-radius,y-radius,z-radius).Magnitude <= radius then
					local new = basePart:Clone()
					new.CastShadow = false
					new.Parent = sphereFolder
					new.Position = worldSpace
					new.CanCollide = false
				end
			end
		end
	end
	return sphereFolder
end
4 Likes