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

How do i set the network owner?

Asked by 8 years ago

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

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

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

0
How did i miss that? CALEB2020 30 — 8y
0
Don't worry, it happens to the best of us. :P adark 5487 — 8y
Ad

Answer this question