Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i set the network owner?

I am trying to set the network owner of a part in a filtering enabled test server from a server script in the server script storage My code is

game.ReplicatedStorage.SpawnCore.OnServerEvent:connect(function(player,args)
	local struct=game.Workspace.Cells.PlayerCells:FindFirstChild(player.Name)
	
	if struct:FindFirstChild("Core") then return end
	local l=game.ServerStorage.ToClone.Cells.Core:Clone()
	l.Parent=struct
	local t=game.Workspace.Spawns:GetChildren()
	l.Position=t[math.random(#t)].Position+Vector3.new(0,10,0)
	wait(1)
	print(l:GetFullName()) --Workspace.Cells.PlayerCells.Player1.Core
	print(player:GetFullName()) --Players.Player1
	l.SetNetworkOwner(player)
end)

It prints the part and the player correctly, but then the SetNetworkOwner false

Workspace.Cells.PlayerCells.Player1.Core
Players.Player1
10:26:11.880 - The function SetNetworkOwner is not a member of "Player"
10:26:11.883 - Script 'ServerScriptService.Spawning', Line 12
10:26:11.889 - Stack End

However, when i call

game.Workspace.Cells.PlayerCells.Player1.Core
:SetNetworkOwner(game.Players.Player1)

from the command bar on the server side, it doesn't error, and the network owner is set

I also tried replacing "l.SetNetworkOwner(player)" with "l.SetNetworkOwner(game.Players.Player1)" Same error.

1 answer

✓ Accepted answer

SetNetworkOwner is a method, not a function. Replace the . with : in your code, and it should work.

2 comments

0

How did i miss that?

0

Don't worry, it happens to the best of us. :P

This discussion is preserved as it was. New answers, comments, and votes are closed.