So, I wanted to try out something where a brick moves to different points with a for loop.
local current = 1
local prts = script.Parent.Model:GetChildren()
local ran = game.Workspace.Part
ran.Material = Enum.Material.Neon
ran.BrickColor = BrickColor.new("Bright red")
ran.Position = prts[1].Position
ran.Orientation = prts[1].Orientation
canR = true
game.Workspace.clik.ClickDetector.MouseClick:Connect(function()
print("starting")
if canR then
canR = false
for i = 0,#prts,1 do
wait(.1)
current = current + 1
ran.CFrame = prts[current].CFrame
ran.Orientation = prts[current].Orientation
if current == 4 then
ran.BrickColor = BrickColor.new("Bright green")
print("Done")
ran.Position = prts[1].Position
ran.Orientation = prts[1].Orientation
wait(1)
ran.BrickColor = BrickColor.new("Bright red")
canR = true
end
end
end
end)
And I got the error
14:21:04.033 - Workspace.Model.Script:17: attempt to index field '?' (a nil value)

4 comments
Actually, just realised the [current], but make sure that isn't a model either
Sorry for the mistake, had a similar problem just now, hence me jumping to conclusions without reading the whole thing. If it really won't work, then try having a folder of Vector3 Values and just move it through those.
Wait, I think I just got it. Could it be becuase, I didn't set current back to 1 again?
This should be a comment.