Part is not a valid member of Workspace "Workspace"

idk why my script isn;t working

  1. What is the issue? Include screenshots / videos if possible!

how to get rid of this error?

image

local n = 5
for number = 1,n do
	print(number,game.Workspace.Part.Position)
	local NewPart = Instance.new("Part")
	NewPart.Parent = game.Workspace
end

On the first iteration of the loop, a part doesn’t yet exist
Instead do:

local n = 5
for number = 1,n do
	local NewPart = Instance.new("Part")
	NewPart.Parent = game.Workspace
    print(number, NewPart.Position)
end
4 Likes