API:Class/BasePart/CanSetNetworkOwnership

CanSetNetworkOwnership

Function of Object Icon.pngBasePart
bool, Variant<string, void> CanSetNetworkOwnership ()

Returns: bool, Variant<string, void>
Description: Verifies whether or not you can call SetNetworkOwner or SetNetworkOwnershipAuto without encountering an error.

Returns true if you can modify/read the network ownership, or returns false + the reason you can't, as a string.

Example

This example checks whether or not the network ownership of the first Object Icon.pngBasePart named "Part" in the Workspace icon.pngWorkspace 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

See Also