Why wont this script work

I tried to make a randomly generated room script, and it was working wen i changed the position of a room without cloning it, but as soon as i started closing it it stopped working…
Please help!

local roomsfolder = game.Workspace:WaitForChild("Rooms")
local roomspawns = game.Workspace:WaitForChild("RoomSpawns")

local roomsfolderchildren = roomsfolder:GetChildren()
local randomroom = nil

for _, v in pairs(roomspawns:GetChildren()) do
	v.Transparency = 1
	randomroom = roomsfolderchildren[math.random(1, #roomsfolderchildren)]
	local ClonedRoom = randomroom:Clone()
	ClonedRoom.Position = v.Position
end
2 Likes

Please can you give some explanation @Vortexuel560

i litrally did… heres more in depth???

I made a baseplate with 4 “spawnpads” and 3 “random rooms”
the script gets a random room and then moved its CLONED version to the selected spawnpad.
it does this for every spawnpad.

it WAS working when i was just changing the rooms position, but now it wont for some reason after i added cloning the rooms.

1 Like

Now I know why nobody is helping you :moyai:
I will try to do it tho

1 Like

im so confused :sob:
what is wrong with my explanation, i try my hardest to explain these thing mans

The game gets the room then moves its cloned version?? what are you exactly trying to do

i think i explained it wrong, here lemem try again

the script will get a possible spawn location for a room right?
so it gets a part that has the coordinates of where a room can spawn.
(we will call this the SpawnPad)

then it gets a random room tha can be spawned at those coordinates.
it goes through a folder and gets a random room
(we will call this the RandomRoom)

then im getting the RandomRoom and cloning it"
then im getting that cloned room and moving it to a possible SpawnPad’s location

Is that a good explanation?

so its not completely random position

no, it spawns at a random possible spawn location, kinda like SCP 3008.

You don’t seem to set the parent for the ClonedRoom. Have you tried adding ClonedRoom.Parent = workspace ?

oh my god your probably right, ill try it, thank you

ill report if it worked or not

Let’s hope the issue was that simple :smiley: If you still need more help, let me know!

thnk you, that did it mans!
char limit

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.