PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

CanSetNetworkOwnership

The CanSetNetworkOwnership function checks whether you can set a BasePart|part's network ownership.

The function’s return value verifies whether or not you can call BasePart/SetNetworkOwner or BasePart/SetNetworkOwnershipAuto without encountering an error. It returns true if you can modify/read the network ownership, or returns false and the reason you can’t, as a string.

##See Also

Returns

Return Type Summary

Whether you can modify/read the network ownership, as well as a reason if you cannot


Code Samples


Check if a Part's Network Ownership Can Be Set

This example checks whether or not the network ownership of the first BasePart named Part in the Workspace can be set.

local part = workspace:FindFirstChild("Part")

if part and part:IsA("BasePart") then
	local canSet,errorReason = part:CanSetNetworkOwnership()
	if canSet then
		print(part:GetFullName().."'s Network Ownership can be changed!")
	else
		warn("Cannot change the Network Ownership of "..part:GetFullName().." because: "..errorReason)
	end
end