Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to use NetworkOwner? Or where to get more information?

Asked by 7 years ago
Edited 7 years ago

I've been trying to use or understant the NetworkOwner, and I can't find information about it.

If I use:

local player = game.Players.Player1
SetNetworkOwner(player)

Does not throw an error, but then, when I use:

print(GetNetworkOwner())

always return nil. There is some other method like GetNetworkOwnershipAuto ( ) or SetNetworkOwnershipAuto ( ) that I just can't understant, is there anyone that know how this work? or how do I make work? or where to get more information about it?

Any help would be appreciated.

1 answer

Log in to vote
4
Answered by 7 years ago
Edited 7 years ago

Firstly more information about Network ownership can be found here.

We are able to set who calculates/simulates the physics in roblox. By default the server will decide who simulates the physics ie the server or a player but only one will do the task and replicate the changes. When a player is close to a part in general the task of simulating the physics will be swapped to that player. This will mean that that player will have the most "up-to-date" physics.

Network ownership functions are available for all base parts ie parts that have physics. We can only set ownership of the parts from the server and cannot set the ownership of anchored parts as it has no physics to simulate.

Some examples:-


-- make a server part local tmp = Instance.new('Part', workspace) tmp.CFrame = CFrame.new(0, 20, 0) tmp:SetNetworkOwner(nil) -- nil is the server -- give a part to each player for them to simulate game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(charModel) local part = Instance.new('Part', workspace) -- the part must be in the game to have physics part.CFrame = CFrame.new(0, 20, 0) part:SetNetworkOwner(plr) end) end)

Side notes:-

You can check if you are able to set the network owner of a part by using CanSetNetworkOwnership else the script will error for parts that have no physics to simulate such as anchored parts.

I hope this helps.

1
Still returns nil when i use part:GetNetworkOwner() LordSalchipapas 96 — 7y
1
It passes back nil or the player, nil is the server. User#5423 17 — 7y
1
Yes, but I set the network -->part:SetNetworkOwner(plr)// then I print --> part:GetNetworkOwner()// and get nil LordSalchipapas 96 — 7y
1
if you play in solo it will be nil, create a local server. User#5423 17 — 7y
View all comments (2 more)
1
Nice, I already test, work good thanks LordSalchipapas 96 — 7y
1
I just want to say thanks because I had the same problem 1 year later :) iGlaciem 72 — 6y
Ad

Answer this question