-- Create smoke for specified part (being destroyed)	

local function createSmoke(targetPart)
	local pos = Vector3.new(0, 0, 0)
	local size = 3
	if targetPart:IsA("Model") and targetPart.PrimaryPart then
		--local plate = targetPart:FindFirstChild("Plate", true)
		local plate = targetPart.PrimaryPart
		pos = plate.Position
		size = 1*plate.Size.X
	else
		pos = targetPart.Position
		size = 1*targetPart.Size.X
	end	
	
	local smokePart = Instance.new("Part")
	smokePart.Name = "SmokePart"
	smokePart.Transparency = 1
	smokePart.CanCollide = false
	smokePart.Anchored = true
	--smokePart.Position = getPositionRelativetoBase(smokePart, pos) + Vector3.new(0, 1, 0)
	smokePart.Position = pos + Vector3.new(0, 1, 0)
	smokePart.Size = Vector3.new(1, 1, 1)
	smokePart.Parent = mapManager.getMap()
	
	local crushSound
	local randomNum = math.random(1,3)
	if randomNum == 1 then
		crushSound = ServerStorage.CrushSound1:Clone()
	elseif randomNum == 2 then
		crushSound = ServerStorage.CrushSound2:Clone()
	elseif randomNum == 3 then
		crushSound = ServerStorage.CrushSound3:Clone()
	end
	crushSound.Parent = smokePart
	if not crushSound.IsLoaded then
		crushSound.Loaded:wait()
	end
	crushSound:Play()

	local smoke = Instance.new("Smoke")
	smoke.Parent = smokePart
	smoke.RiseVelocity = 0
	smoke.Size = size

	DebrisService:AddItem(smokePart, 2)
end
