So, In a test game I'm making, you spawn in a room. You touch a button, and it picks a room randomly from lighting, clones it in, teleports you to the room, and deletes the last room you were in. There's another button in the new room, which does the same thing as the last room (so its basically an endless assortment of rooms). This works fine in test mode, however in an actual server, it fails to work. When i hit the button, it teleports me to the middle of the baseplate, and no room spawns in. A singular script is incharge of the random room picking. This is the script:
t = script.Parent
t.Changed:connect(function()
print("Changing Room...")
local r = math.random(1,3)
if r == 1 then
game.Lighting.defroom1:Clone().Parent = workspace
game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom1.spawn.Position)
elseif r == 2 then
game.Lighting.defroom2:Clone().Parent = workspace
game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom2.spawn.Position)
elseif r == 3 then
game.Lighting.defroom3:Clone().Parent = workspace
game.Workspace.Player.Torso.CFrame = CFrame.new(game.Workspace.defroom3.spawn.Position)
end
end)
(NOTE: The script is located in Workspace > ValueHold (A folder I made) > RoomCount (A number Value) > This script)

1 comment
I don't see an error in your script. Does the output show anything? Also, instead of keeping models in Lighting, use ServerStorage