NetworkOwnerService
Tracks a stack of owners so ownership isn't reverted or overwritten in delayed network owner set. Deduplicates network ownership handles.
Setup
-- Server.lua
local serviceBag = require("ServiceBag")
serviceBag:GetService(require("NetworkOwnerService"))
serviceBag:Init()
serviceBag:Start()
Usage
local networkOwnerService = serviceBag:GetService(NetworkOwnerService)
-- Force this part to be owned by the server
local handle = networkOwnerService:AddSetNetworkOwnerHandle(workspace.Part, nil)
delay(2.5, function()
-- oh no, another function wants to set the network owner, guess we'll be owned by Quenty for a while
local handle = networkOwnerService:AddSetNetworkOwnerHandle(workspace.Part, Players.Quenty)
delay(1, function()
-- stop using quenty, guess we're back to the server now
handle()
end)
end)
delay(5, function()
handle() -- stop forcing network ownership to be the server, now we're back to nil
end)
Functions
Init
NetworkOwnerService:
Init
(
) →
(
)
Initializes the NetworkOwnerService. Should be done via ServiceBag.
AddSetNetworkOwnerHandle
Tries to set the network owner handle to the given player.