So im currently following a gnome code tutorial for randomly generated rooms like the game ‘doors’ but currently encountered an error called
ServerScriptService.Server.Plots:15: attempt to index nil with 'CFrame'
Heres the code:
--Server Script
local plots = require(script.Plots)
local prevPlots = workspace.Plains_Start
for i=1, 10 do
plots:Generate(prevPlots)
print("generate")
end
--Module Script
local plots = {}
plots.random = Random.new()
function plots.Generate(prevPlots)
local possiblePlots = workspace.Plots:GetChildren()
local randomPlots = possiblePlots[plots.random:NextInteger(1, #possiblePlots)]
local newPlots = randomPlots:Clone()
newPlots.PrimaryPart = newPlots.Start
newPlots:PivotTo(prevPlots.End.CFrame)
newPlots.Parent = workspace.Generated
return newPlots
end
return plots
And i did check that the ‘End’ does exist and the path is right.
When i tried to print the name of the prevPlots on the module script it just printed nil