Network Ownership Lag when Dropping Items?

  1. What do you want to achieve?
    I’m trying to make an inventory system that lets you pick up and drop items.
    When you drop, the items are affected by physics and brought to the ground.
    When items are picked up, their network ownership gets passed to the player.

  2. What is the issue?
    There’s a noticeable delay to other clients when the item is dropped.
    https://gyazo.com/d109456092683455de3c8f9c1795495f

  3. What solutions have you tried so far?
    I tried removing the lines that pass the network ownership to the player, but that just ends up creating a delay for both clients.
    I did look around the forum, but none of the posts related to network ownership seem to be helping, or are just unrelated to my situation and I don’t understand them.

Basically, in the Gif above you can see on the left screen that the item dropped by the other player has a delay before physics affect it.

The ModuleScript I made on the server to give and take items from players and Humanoids alike.
function ServerInventoryModule:GiveItem(InventoryFolder,SlotValue,ItemValue,Clone,Player)
	if SlotValue.Value then
		return SlotValue.Name.." already has an item value."
	end
	
	
	if Clone then
		ItemValue = ItemValue:Clone()
	end
	
	ItemValue:SetAttribute("Pickable",false)
	
	local ItemModel = ItemValue.Value
	if ItemModel then
		ItemModel.Parent = workspace
		
		for _,BasePart in pairs(ItemModel:GetDescendants()) do
			if BasePart:IsA("BasePart") then
				BasePart:SetNetworkOwner(Player)
			end
		end
		
		ItemModel.Parent = ReplicatedStorage
	end
	
	ItemValue.Parent = InventoryFolder.Items
	SlotValue.Value = ItemValue
end

function ServerInventoryModule:DropItem(SlotValue,Origin,IsDead,Player)
	local ItemValue = SlotValue.Value
	if not ItemValue then
		return SlotValue.Name.." has no item value."
	end
	
		
	local ItemModel = ItemValue.Value
	if ItemModel then
		ItemValue.Parent = workspace
		ItemModel.Parent = ItemValue
		ItemModel:PivotTo(Origin)
		
		local PrimaryPart = ItemModel.PrimaryPart
		if PrimaryPart then
			local AngleRandom = Random.new():NextNumber(-10,10)
			PrimaryPart.AssemblyAngularVelocity = Vector3.new(AngleRandom,AngleRandom,AngleRandom)
			
			if IsDead then
				local LinearRandom = Random.new():NextNumber(-20,20)
				PrimaryPart.AssemblyLinearVelocity = Vector3.new(LinearRandom,0,LinearRandom)
			end
		end
		
		task.spawn(function()
			task.wait(1)
			ItemValue:SetAttribute("Pickable",true)
			for _,BasePart in pairs(ItemModel:GetDescendants()) do
				if BasePart:IsA("BasePart") then
					BasePart:SetNetworkOwner()
				end
			end
		end)
	else
		ItemValue:Destroy()
	end
	
	SlotValue.Value = nil
end

In simple steps:

  1. Player picks up item
  2. Parent item ObjectValue to their inventory folder
  3. Set item model’s network owner to player
  4. Parent item model to ReplicatedStorage
  5. Player drops item
  6. Parent item ObjectValue to workspace
  7. Parent item model to item ObjectValue
  8. Set item model network owner to server after 1 second

Is the problem inevitable?
Am I using SetNetworkOwner() wrong?

Thanks for reading :slight_smile:

Why are you setting the network owner after 1 second? Shouldn’t you set it as soon as the item is dropped?

I’ve seen that in the video that you’ve attached the delay is 1s. This is the time it takes to set the network owner.

Can you change it so it sets the network owner as soon as possible? Also, can you give me your results after this change?

1 Like

My computer crashed right after the Gif finished recording lmao

Here are the results:
https://gyazo.com/0de8119dae497ae425531e89840f542f
Unfortunately, there’s now a delay for all players now.

Huh, that’s interesting. I’ve reviewed your code and just a quick question, why don’t you use BasePart:ApplyImpulse()
and BasePart:ApplyAngularImpulse() instead of manually setting the AssemblyLinearVelocity and AssemblyAngularVelocity?

EDIT: Just realized that if the part is owned from the server these functions must be called from the server et vice-versa, so watch out.

Also, can you try now making it wait more than 1 second before setting the network owner? I’m just curious if that might somehow fix the problem. Thanks.

1 Like

I made it wait 5 seconds, same results.
https://gyazo.com/7c2bc94c5f89c1968f6eceebd7af3a70

Did you try setting it back to setting the network owner instantly and, at the same time, using ApplyImpulse? Please let me know because I’m not completely sure if this is something that we can control.

Same thing :frowning:
https://gyazo.com/589c9aba24f7dd83ba25a4f25eecc4ae

for _,BasePart in pairs(ItemModel:GetDescendants()) do
	if BasePart:IsA("BasePart") then
		BasePart:SetNetworkOwner()
	end
end

local PrimaryPart = ItemModel.PrimaryPart
if PrimaryPart then
	PrimaryPart:ApplyImpulse(Vector3.new(Random.new():NextNumber(-20,20),0,Random.new():NextNumber(-20,20)))
end

Is there a way to disable automatic Emojis by the way? They look lifeless :skull:

Update:
I thought about simply making it so every client will parent the item model by itself instead of making the server do that.
However, I’m not sure how reliable that would be, since exploiters could probably abuse that, and there can be differences between clients which will be annoying.

setting NetworkOwner to a player lets a player render the physics and replicate it to the server who then replicates it to the other players. The delay in it/lag comes from the time it takes to replicate what the owner sees. sadly there isn’t a real solution other than making it client sided which has its own issues.

1 Like

Oh well, this problem is not too critical anyway. I just saw other developers manage to make player ragdolls be smooth, but from what I read it’s mostly related to the motors.
Thank you anyway!

Edit: Actually, I’ll see if not changing the network owner at all will make it smooth.
If it won’t work, I’ll mark your reply as a solution.

Just tested it out, and nope, still the same results.
I guess I’ll just deal with it, it’s not that much of a problem anyway.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.