r/robloxrooms • • 10d ago

Why am i doing wrong?

Tutorial i follow:https://www.youtube.com/watch?v=AbUJd5cvuPE&list=PLPTEPcIhVuC67HZKp_S_7zoZE9qFdFYuB&index=2

Code 1:

local room = {}

room.random = Random.new()

function room.generate(prevroom: Model, int: number)

local potential = game.ServerStorage:GetChildren()

lolcal newroom = potential\[room.random:NextInteger(1, potential)\]:Clone()



newroom:pivotTo(prevroom.exit.cframe)



workspace.LatestRoom.Value = newroom

newroom.Parent = workspace.generatedrooms



return newroom

end

return room

Code 2:

local room = require(script:WaitForChild("room"))

local generate = game.ServerStorage.bindableEvents:WaitForChild("Generate")

local prevroom = workspace.lobby

generate.Event:Connect(function()

prevroom = room.generate(prevroom)

end)

for i = 1, 5 do

generate:fire()

end

2 Upvotes

4 comments sorted by

1

u/cool101wool 9d ago

hi
can you attach images of the full code and where it is inside of explorer (or a place file with just the bare minimum that contains whats going on that shouldn't be and nothing else) so its easier to see

1

u/MGE_FAN-TF2 9d ago

There ya go

1

u/cool101wool 9d ago

things i noticed:

rint is a count with 1 added and then 1 is added again to it in rint1 so the first room would be A-002

maybe you should swap lines 1 and 3 of generate script if nothing happens at all, not sure though

check if:

the attribute of GenerateRooms "Section" is a string and not a number (the contents of the string will point it into what folder in serverstorage to list the rooms inside of it)

primaryparts are set correclty (when you are setting the pivot of the room, if the room does not have its primarypart set it most likely wont align up correctly)

no instances are missing

also you should check the output and also tell what is truely going on instead of "Why am i doing wrong?"