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

Why the heck isn't network ownership being set?

Item is a tool. I am trying to make a tool that is throwable. Server Code:

local Model = Item:FindFirstChildWhichIsA("Model")
for _, v in pairs(Item:GetDescendants()) do
	if v:IsA("BasePart") then
		v:SetNetworkOwner(Player)
		v.CanCollide = false
	end
end
Humanoid:LoadAnimation(ThrowAnimation):Play()
wait(0.25)
Model.Parent = workspace
ThrowEvent:FireClient(Player, Model.PrimaryPart, Item)
local LocalScript = Item:FindFirstChildWhichIsA("LocalScript")
LocalScript.Parent = Character
LocalScripts[Model.PrimaryPart] = LocalScript
Item:Destroy()

Client code:

ThrowEvent.OnClientEvent:Connect(function(Part, Item)
	if Item ~= script.Parent then return end
	local Velocity = Instance.new("BodyVelocity", Part)
	Velocity.Velocity = ((Player:GetMouse().Hit.p - Part.Position).Unit*100)
	delay(0.2, function()
		Velocity:Destroy()
	end)
	local Name = Item.Name
	Part.Touched:Connect(function(Hit)
		for _, v in pairs(Character:GetDescendants()) do
			if Hit == v then return end
		end
		ThrowEvent:FireServer(Part.Position, Part, Name)
	end)
end)

WhY doEsN'T iT sEt ThE NeTwOrK OwNeR? I can still see hops? Why? How come it completely ignores my calls to :SetNetworkOwner()? This is EXTREMELY frustrating, I have no idea what's going on and I want to scream.

Help. Why is it that it is ignoring my EXPLICIT setting of ALL of the parts' network ownership in the tool to Player

Surely there's a better way than THIS:

spawn(function()
	while v:IsDescendantOf(workspace) do
		v:SetNetworkOwner(Player)
		wait()
	end
end)

There MUST be a more sensible way. I mean, why should I have to repeatedly set the network owner? Why is :SetNetworkOwner() broken?

1 answer

For some reason, I need to set the network owner after I move the part to the workspace and remove the tool. For some reason, being part of or connected to the tool automatically screws up the network ownership.

local Model = Item:FindFirstChildWhichIsA("Model")
Humanoid:LoadAnimation(ThrowAnimation):Play()
wait(0.25)
Model.Parent = workspace
ThrowEvent:FireClient(Player, Model.PrimaryPart, Item)
local LocalScript = Item:FindFirstChildWhichIsA("LocalScript")
LocalScript.Parent = Character
LocalScripts[Model.PrimaryPart] = LocalScript
Item:Destroy()
for _, v in pairs(Item:GetDescendants()) do
    if v:IsA("BasePart") then
        v:SetNetworkOwner(Player)
        v.CanCollide = false
    end
end

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