Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Sphere
- -- Quoteory
- -- August 8, 2019
- --[[
- --]]
- local Sphere = {}
- local spherePart = Instance.new("Part")
- spherePart.BrickColor = BrickColor.White()
- spherePart.Anchored = true
- function inRadius(Mag, minRadius, maxRadius)
- return Mag >= minRadius and Mag <= maxRadius
- end
- function Sphere:Create(Radius, PartSize, Parts, Position)
- local Parts = Parts/3
- local centerCFrame = CFrame.new(Position)
- local SizeX = PartSize.X
- local Width = SizeX * Parts
- for x = 1, Parts do
- for y = 1, Parts do
- for z = 1, Parts do
- local Offset = CFrame.new(-(Width/2)-SizeX/2, -(Width/2)-SizeX/2, -(Width/2)-SizeX/2)
- local CF = centerCFrame * CFrame.new(SizeX * x, SizeX*y, SizeX * z) * Offset
- local minRadius, maxRadius = Radius - SizeX, Radius + SizeX
- local isInRadius = inRadius(math.floor((centerCFrame.Position - CF.Position).magnitude), minRadius, maxRadius)
- if isInRadius then
- local newPart = spherePart:Clone()
- newPart.Size = PartSize
- newPart.CFrame = CF
- newPart.Parent = workspace
- end
- end
- end
- end
- end
- return Sphere
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement