ServerStorage

Show Deprecated
Not Creatable
Service
Not Replicated

A container whose contents are only accessible on the server. Objects descending from ServerStorage will not replicate to the client and will not be accessible from LocalScripts.

As ServerStorage is a service it can only be accessed using the DataModel.GetService method.

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

Scripts will not run when they are parented to ServerStorage, although ModuleScripts contained within can be accessed and ran. It is recommended developers use ServerScriptService to hold Scripts they wish the server to execute.

Note that as the contents of ServerStorage can only be accessed by the server, its contents will need to be parented elsewhere (such as Workspace) before clients can access them. Developers who require a container that is accessible by both the server and client are advised to use ReplicatedStorage instead.

Code Samples

ServerStorage Map Rotation

1local ServerStorage = game:GetService("ServerStorage")
2
3local ROUND_TIME = 5
4
5local map1 = Instance.new("Model")
6map1.Name = "Map1"
7map1.Parent = ServerStorage
8
9local map2 = Instance.new("Model")
10map2.Name = "Map2"
11map2.Parent = ServerStorage
12
13local map3 = Instance.new("Model")
14map3.Name = "Map3"
15map3.Parent = ServerStorage
16
17local maps = { map1, map2, map3 }
18local RNG = Random.new()
19local currentMap = nil
20local lastPick = nil
21
22while true do
23 print("New map!")
24
25 -- remove current map
26 if currentMap then
27 currentMap:Destroy()
28 end
29
30 -- pick a map
31 local randomPick = nil
32 if #maps > 1 then
33 repeat
34 randomPick = RNG:NextInteger(1, #maps)
35 until randomPick ~= lastPick
36 lastPick = randomPick
37 end
38
39 -- fetch new map
40 local map = maps[randomPick]
41 currentMap = map:Clone()
42 currentMap.Parent = workspace
43
44 task.wait(ROUND_TIME)
45end

Summary

Properties

Events

Methods

Properties

Events

Methods