Hi, I have a problem with changing network ownership.
----- CONFIGURATION -----
local DROP_INTERVAL = 5
local SHOULD_DROP = true
local TO_DROP = game.ServerStorage.TycoonAssets.Droppings.Car
----- DO NOT TOUCH BELOW. -----
local Dropper = script.Parent
local DropperHead = Dropper.Head
local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Modules = ServerScriptService:WaitForChild("Modules")
local PassStock = require(Modules:WaitForChild("PassStock"))
while wait(DROP_INTERVAL) do
if SHOULD_DROP then
local clonedDropping = TO_DROP:Clone()
clonedDropping.Parent = workspace.Droppings
if clonedDropping:IsA("BasePart") then
clonedDropping.Position = Vector3.new(DropperHead.Position.X, DropperHead.Position.Y - 5, DropperHead.Position.Z)
local PlayerID = script.Parent.Parent.Owner.Value
local Player = Players:GetPlayerByUserId(PlayerID)
clonedDropping:SetNetworkOwner(Player)
else
clonedDropping:MoveTo(Vector3.new(DropperHead.Position.X, DropperHead.Position.Y - 5, DropperHead.Position.Z))
local PlayerID = script.Parent.Parent.Owner.Value
local Player = Players:GetPlayerByUserId(PlayerID)
clonedDropping.PrimaryPart:SetNetworkOwner(Player)
end
clonedDropping.Owner.Value = script.Parent.Parent.Owner.Value
end
end
This yields the error “Can only call Network Ownership API on a part that is descendant of Workspace”.
I have tried adding a wait(1) but to no avail.
You trying to setNetworkOwner To a Player Instance
You must setNetwork to his Character:
local DROP_INTERVAL = 5
local SHOULD_DROP = true
local TO_DROP = game.ServerStorage.TycoonAssets.Droppings.Car
----- DO NOT TOUCH BELOW. -----
local Dropper = script.Parent
local DropperHead = Dropper.Head
local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Modules = ServerScriptService:WaitForChild("Modules")
local PassStock = require(Modules:WaitForChild("PassStock"))
while wait(DROP_INTERVAL) do
if SHOULD_DROP then
local clonedDropping = TO_DROP:Clone()
clonedDropping.Parent = workspace.Droppings
if clonedDropping:IsA("BasePart") then
clonedDropping.Position = Vector3.new(DropperHead.Position.X, DropperHead.Position.Y - 5, DropperHead.Position.Z)
local PlayerID = script.Parent.Parent.Owner.Value
local Player = Players:GetPlayerByUserId(PlayerID)
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
clonedDropping:SetNetworkOwner(PlayerCharacter)
else
clonedDropping:MoveTo(Vector3.new(DropperHead.Position.X, DropperHead.Position.Y - 5, DropperHead.Position.Z))
local PlayerID = script.Parent.Parent.Owner.Value
local Player = Players:GetPlayerByUserId(PlayerID)
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
clonedDropping.PrimaryPart:SetNetworkOwner(PlayerCharacter)
end
clonedDropping.Owner.Value = script.Parent.Parent.Owner.Value
end
end
I figured it out, the PrimaryPart was incorrectly set.
You are actually meant to set to the Player, not their character as you are granting the player itself the ownership.