ServerStorage

Mostrar obsoleto
Não criável
Serviço
Não replicado

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.

Amostras de código

ServerStorage Map Rotation

local ServerStorage = game:GetService("ServerStorage")
local ROUND_TIME = 5
local map1 = Instance.new("Model")
map1.Name = "Map1"
map1.Parent = ServerStorage
local map2 = Instance.new("Model")
map2.Name = "Map2"
map2.Parent = ServerStorage
local map3 = Instance.new("Model")
map3.Name = "Map3"
map3.Parent = ServerStorage
local maps = { map1, map2, map3 }
local RNG = Random.new()
local currentMap = nil
local lastPick = nil
while true do
print("New map!")
-- remove current map
if currentMap then
currentMap:Destroy()
end
-- pick a map
local randomPick = nil
if #maps > 1 then
repeat
randomPick = RNG:NextInteger(1, #maps)
until randomPick ~= lastPick
lastPick = randomPick
end
-- fetch new map
local map = maps[randomPick]
currentMap = map:Clone()
currentMap.Parent = workspace
task.wait(ROUND_TIME)
end

Propriedades

Métodos

Eventos