Skip to main content

ServerHidden

Inherits from Instance

A service which stores contents only accessible to the server. Objects in this service will not replicate to the client and are not accessible from LocalScripts

Not Creatable Service

Summary

The ServerHidden service can be accessed from server Scripts using game["ServerHidden].

By storing large objects such as maps in ServerHidden until they are needed, network traffic will not be used up transmitting these objects to the client when they join the game.

As the contents are only accessible to the server, the contents will need to be parented elsewhere such as Environment before clients can access them. Developers who require a container that is accessible by both the server and client are advised to use Hidden instead.

Code Samples

ServerHidden Map Rotation

This is a simple example of how multiple map system can be made using ServerHidden.

It creates three dummy models that are parented to ServerHidden. Then it will load a random map and wait a specified duration on a loop.

You should consider measures to ensure players respawn correctly or go to a lobby during intermission periods.

local ServerHidden = game["ServerHidden"]

local map1 = Instance.new("Model")
map1.Name = "Map1"
map1.Parent = ServerHidden

local map2 = Instance.new("Model")
map2.Name = "Map2"
map2.Parent = ServerHidden

local maps = { map1, map2}
local random = Random.new()
local currentMap = nil
local lastPick = nil

while true do
print("New map!")

if currentMap then
currentMap:Destroy()
end

local randomPick = nil
if #maps > 1 then
repeat
randomPick = random:NextInteger(1, #maps)
until randomPick ~= lastPick
lastPick = randomPick
end

local map = maps[randomPick]
currentMap = map:Clone()
currentMap.Parent = game["Environment"]

task.wait(ROUND_TIME)
end