infinitely generated rooms, works in studio but not in-game. why is this?
Asked by
3 years ago Edited 3 years ago
hi, i have a code that creates a new room as you walk along, the point of the game is just to open doors infinitely.
this is my code:
01 | local Players = game:GetService( "Players" ) |
05 | local function OnCharacterAdded(char) |
06 | while char.Humanoid.Health > 0 do |
09 | local zPos = math.floor((char.HumanoidRootPart.Position.Z + i * 100 ) / 100 + 0.5 ) * 20 |
10 | if visited [ zPos ] = = nil then |
11 | visited [ zPos ] = script.Room:Clone() |
12 | local p = visited [ zPos ] |
14 | p:SetPrimaryPartCFrame(CFrame.new(Vector 3. new( 0 , 1.5 ,zPos))) |
16 | p.Parent = workspace.Room |
22 | local function OnPlayerAdded(plr) |
24 | OnCharacterAdded(plr.Character) |
26 | plr.CharacterAdded:Connect(OnCharacterAdded) |
29 | for _, Player in ipairs (Players:GetPlayers()) do |
33 | Players.PlayerAdded:Connect(OnPlayerAdded) |
it only works in studio for some reason, and in-game it gives me errors along the lines of "execution time exhausted" and I have no idea how to fix it.
i've made several posts on the dev forums and got no help, so I'm posting here in hopes of getting an actual answer that helps
thank you