Problem with alvinblox mining simulator shop tutorial part 1

Im making a game with my friends.I wanted to make shop like in mining simulator so i followed alvinblox’s toturial but meet a problem at his first part that is when i run the game it shows an error
ServerScriptService.Script:11: attempt to index nil with ‘CFrame’

-- Generate Blocks

local numberOfBlocks = #game:GetService("ServerStorage"):WaitForChild("ToolModels"):GetChildren()

local studGap = 9 -- Gap between each box

local box = game.Workspace:WaitForChild("ItemRoller").Box0

for i = 1, numberOfBlocks-1,1 do --Looping through all of the boxes
	newbox = box:Clone()
	newbox:SetPrimaryPartCFrame(newbox.PrimaryPart.CFrame * CFrame.new(16*i,0,0))
	newbox.Name = "Box"..i
	newbox.Parent = game.Workspace.ItemRoller
end

for i, v in pairs(game.ServerStorage.ToolModels:GetChildren()) do
	if v then
		new = v:Clone ()
		new:SetPrimaryPartCFrame(game.Workspace.ItemRoller["Box"..i-1].Hitbox.CFrame)
		new.Parent = game.Workspace.ItemRoller["Box"..i-1]
	end
end

I searched alot in developer forum but couldnt find solution for this problem.

1 Like

Whatever model “newbox” represents doesn’t have its “PrimaryPart” property set.

I dont have newbox model i have box0 model

set the models PrimaryPart for :SetPrimaryPartCFrame to work

but how to do it always everything was working normally