Before I start, I want to say that I did not make this script, I got it from "The Power of CFrames" guide.
Error: ServerScriptService.Script:17: attempt to index local 'lastPart' (a nil value)
I know this error is coming from not returning it.
Basically I am asking, why does it not error when we make the part the first time?"
Here is the script:
local start = Instance.new("Part", workspace)
start.CFrame = CFrame.new(0, 10, 0)
start.Anchored = true
local slowness = .1
local useSlow = true
local function newPart(lastPart, angle, slow)
local function doWait() -- This function will add pauses to the CFraming so we can understand it more.
if slow then
wait(slowness)
end
end
local new = lastPart:Clone()
new.Parent = workspace
new.CFrame = lastPart.CFrame
doWait()
new.CFrame = new.CFrame * CFrame.new(new.Size.X/2, 0, 0)
doWait()
new.CFrame = new.CFrame * CFrame.Angles(0, 0, math.rad(angle))
doWait()
new.CFrame = new.CFrame * CFrame.new(new.Size.X/2, 0, 0)
--return new
end
for angle = 10, 360, 10 do
start = newPart(start, 10, useSlow)
end

1 comment
Thanks, it helped a lot.