I have a room generation script, it sometimes doesnt have the error, and sometimes does, and im having trouble fixing it The thing is, when that happens, a huge or small part of rooms won't generate
local rooms = game.ReplicatedStorage:WaitForChild("Rooms"):GetChildren() for i, placeHolder in pairs(game.Workspace.PlaceHolder:GetChildren()) do local chosenRoom = rooms[math.random(1,#rooms)]:Clone() chosenRoom.PrimaryPart = chosenRoom.Part local rotation = math.random(0,2) if rotation == 0 then chosenRoom:SetPrimaryPartCFrame(placeHolder.CFrame) elseif rotation == 1 then chosenRoom:SetPrimaryPartCFrame(placeHolder.CFrame * CFrame.Angles(0,math.rad(-90),0)) else chosenRoom:SetPrimaryPartCFrame(placeHolder.CFrame * CFrame.Angles(0,math.rad(90),0)) end placeHolder:Destroy() chosenRoom.Parent = game.Workspace end
this is the code, if anyone can help, itd be appreciated, thanks.
Your loop was running too many times per second put in a wait(1) in your loop so it doesnt break.