Why does my script only work in studio?

Hello, I have a code that procedurally generates rooms as you walk along.
But for some reason, it only works in studio?

Here are some videos

Studio

Actual Game

https://www.roblox.com/games/7246027585/walk-through-doors-forever-simulator
i couldn’t upload a video for some reason so see for yourself in the actual game

any help is appreciated, thank you in advance

1 Like

did you clicked save to roblox instead of publish to roblox?

Without any code, we can’t really tell what is going on.

Can you send us photos of errors if there is any in the actual game? You can check it by saying /console

apologies, here is the code i wrote for the game

local visited = {}
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		while char.Humanoid.Health > 0 do
			wait()
			for i = -10,1 do
				local zPos = math.floor((char.HumanoidRootPart.Position.Z + i * 100) / 100 + 0.5) * 20
				if visited[zPos] == nil then
					visited[zPos] = script.Room:Clone()
					local p = visited[zPos]

					p:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,1.5,zPos)))

					p.Parent = workspace.Room
				end
			end
		end
	end)
end)

any ideas?

i tried that, but it just tells me it failed since no changes were detected

Here are some solutions that may help you:

  • Publish the game and Save it to Roblox
  • Commit the scripts if you are in a Team Create

here is a screenshot from the F9 console

check the stacktrace. what’s line 28?

Pretty sure that is a backdoor inside of multiple parents trying to do something.

Perform CTRL + SHIFT + F, then search for these keywords require, getfenv, insertservice, marketplaceservice and you can try to search for scripts in explorer and see what is the script inside of that Mesh. Most likely a backdoor due to the multiple parents and the weird location.

For other script, the for loop gets exhausted. I have sent a direct message in Discord to you for help.