im making an elevator game and i have each floor stored in a table. im trying to make it so it wont spawn the same floor twice in a row. this is what i currently have.
game.ReplicatedStorage.Floors.TestFloor1,
game.ReplicatedStorage.Floors.TestFloor2,
game.ReplicatedStorage.Floors.TestFloor3
}
local chosenFloor
local previousFloor = -1
while true do
repeat
chosenFloor = floors[math.random(#floors)]
until chosenFloor ~= previousFloor
previousFloor = chosenFloor
chosenFloor:Clone()
chosenFloor.Parent = workspace
chosenFloor:PivotTo(workspace.Elevator.FloorSpawn.CFrame)
task.wait(1)
chosenFloor:Destroy()
end
if you need me to elaborate more i can. im relatively new to roblox scripting, so dont be harsh