# How to create a crater?

Im working on a fighting game with abilities and I was wondering how to make like a crater around the player with the same color and material as the ground, do I make each part seperate for the crater?

The way I make them is something around this:

``````-- for reference, partCount is the amount of parts in the crater
-- craterCFrame is the CFrame of the center
-- and offset is the distance from the center
for index = 1, partCount do
-- use pi to get the radians in a circle, then multiply by the
-- fraction of (index / partCount) to get the direction we want to move the
-- part in
local rotation = craterCFrame * CFrame.Angles(0, math.pi * 2 * (index / partCount), 0)
local rockCFrame = craterCFrame + rotation.LookVector * offset
-- create the part, make sure to randomize the rotation of "rockCFrame" too!
end
``````

The end result came out as something like this

``````local partCount = 8
local offset = 4.5
local craterCFrame = CFrame.new(0, 8, 0)

local cast = workspace:Raycast(craterCFrame.Position + craterCFrame.UpVector, craterCFrame.UpVector * -25)
if not cast then
return
end

craterCFrame = CFrame.new(cast.Position) * craterCFrame.Rotation

local rng = Random.new()
for index = 1, partCount do
local rotation = craterCFrame * CFrame.Angles(0, math.pi * 2 * (index / partCount), 0)
local rockCFrame = (craterCFrame + rotation.LookVector * offset) * CFrame.Angles(
rng:NextNumber(-math.pi, math.pi),
rng:NextNumber(-math.pi, math.pi),
rng:NextNumber(-math.pi, math.pi)
)
local rock = Instance.new("Part")
rock.Size = Vector3.one * 3
rock.CFrame = rockCFrame
rock.Material = cast.Instance.Material
rock.Color = cast.Instance.Color
rock.Parent = workspace
end
``````

^^ Code used to recreate the result in the image