This is a ServerScript in ServerScriptService, There are models called "Room1", "Room2", etc, in Replicated Storage. The Rooms are cloned into the model of GameRooms. But, when the clones do go into GameRooms, the function of ChildAdded does not work. Nothing gets printed.
local GameRooms = game.Workspace.GameRooms
local RoomNumber --(RoomNumber is IntValue found in player's leaderstats)
GameRooms.ChildAdded:Connect(function(Added)
print(Added)
if Added.Name == "Room"..RoomNumber.Value then
local Room = Added.Name
local Button = GameRooms[Room].Button
local ClickDetector = Button.ClickDetector
ClickDetector.MaxActivationDistance = 7
local Door = GameRooms[Room].Door
ClickDetector.MouseClick:Connect(function()
Click(Door)
end)
end
end)
