Network Ownership API cannot be called on Anchored parts or parts welded to anchored parts

Hello there, recently my horse broke due to a recent update about the ControlScripts being updated, and when I fixed it I received another error saying “Network Ownership API cannot be called on Anchored parts or parts welded to anchored parts.” Does anyone know what this means or how to fix it? I’ve included the error message, part of the code where the error is at, and the full code in case anyone needs to take a look at the whole script. If anyone knows how to fix this please let me know

Code where the Error is at
if target and (mouse.Hit.p-player.Character.HumanoidRootPart.Position).magnitude < 10 and mouse.Target.Parent.Name == "BrownHorse" or "WhiteHorse" or "BuckskinHorse" or "GreyHorse" or "BlackHorse" or "ChesnutHorse" then
			game.ReplicatedStorage.Events.Mount:InvokeServer(mouse.Target.Parent)
		end
Error Message

Full Code
local Camera = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local running = true
-- variables you have
local controlToggle = false
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

local InputService = game:GetService("UserInputService")
local keysDown = {}


InputService.InputBegan:connect(function(input,processed)
	if processed then return end
	
	keysDown[input.KeyCode] = true
end)

InputService.InputEnded:connect(function(input,processed)
	if processed then return end
	
	keysDown[input.KeyCode] = false
end)


--Where it begins
local UIS = game:GetService("UserInputService")
local Key = Enum.KeyCode.F

UIS.InputBegan:connect(function(Input,GPE)
    if not GPE then
        if Input.KeyCode == Key then
	if player.Character:FindFirstChild("HumanoidRootPart") ~= nil then
		local target = mouse.Target
		if target and (mouse.Hit.p-player.Character.HumanoidRootPart.Position).magnitude < 10 and mouse.Target.Parent.Name == "BrownHorse" or "WhiteHorse" or "BuckskinHorse" or "GreyHorse" or "BlackHorse" or "ChesnutHorse" then
			game.ReplicatedStorage.Events.Mount:InvokeServer(mouse.Target.Parent)
		end
			end
end
end
end)



----------------------------------------------------------------------------

while wait() do
	--player.PlayerScripts.ControlScript.Disabled = player.Horse.Value ~= nil
	while wait() do
	if player.Horse.Value ~= nil and not controlToggle then
		Controls:Disable()
		controlToggle = true
	elseif player.Horse.Value == nil and controlToggle then
		Controls:Enable()
		controlToggle = false
	
	if player.Horse.Value then -- Horse Control
		player.Character.Humanoid.AutoRotate = false
		local horse = player.Horse.Value
		local settings = require(game.ReplicatedStorage.HorseSettings)
		local gait = 1
		local oldgait = 0
		local rotate = 0
		
		local x, y, z = horse.HumanoidRootPart.CFrame:toEulerAnglesXYZ()
		
		if math.abs(z) > 0.1 then
			y = -y
		else
			y = math.pi+y
		end
		
		local gaitDebounce = false
		local sitAnim = player.Character.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.HorseSit)
		sitAnim:Play()
		
		while player.Horse.Value and player.Horse.Value:FindFirstChild("HumanoidRootPart") do
			
			if gait ~= oldgait then -- Horse animations
				oldgait = gait
				if gait == 1 then
					spawn(function()
						game.ReplicatedStorage.Events.Animate:InvokeServer(game.ReplicatedStorage.Animations.HorseBreath,horse)
						for i = 0, 2, 1/30 do
								wait()
								if not player.Horse.Value then return end
							end
						while wait() and gait == 1 and player.Horse.Value do
							local a
							local list = {}
							
							for i, k in ipairs(settings.IdleAnimations) do
								for j = 1, k.Weight do
									list[i+j-1] = k
								end
							end
							
							local a = list[math.random(1,#list)]
							
							game.ReplicatedStorage.Events.Animate:InvokeServer(a.Anim,horse)
							
							for i = 0, a.Length, 1/30 do
								wait()
								if not player.Horse.Value then return end
							end
						end
					end)
				else
					local a = settings.Gaits[gait].Animation
					game.ReplicatedStorage.Events.Animate:InvokeServer(a,horse)
				end
			end
			
			local speed = settings.Gaits[gait].Speed
			
			if keysDown[Enum.KeyCode.A] then
				rotate = math.min(rotate + 6/speed,60/speed)
			elseif keysDown[Enum.KeyCode.D] then
				rotate = math.max(rotate - 6/speed,-60/speed)
			elseif rotate ~= 0 then
				if math.abs(rotate) < 0.2 then
					rotate = 0
				else
					rotate = (math.abs(rotate) - 6/speed) * rotate/math.abs(rotate)
				end
			end
			if keysDown[Enum.KeyCode.W] and not gaitDebounce then
				gait = math.min(gait + 1,#settings.Gaits)
				gaitDebounce = true
				spawn(function()
					wait(0.3)
					repeat wait() until not keysDown[Enum.KeyCode.W]
					gaitDebounce = false
				end)
			end
			if keysDown[Enum.KeyCode.S] and not gaitDebounce then
				gait = math.max(gait - 1,1)
				gaitDebounce = true
				spawn(function()
					wait(0.8)
					repeat wait() until not keysDown[Enum.KeyCode.S]
					gaitDebounce = false
				end)
			end
			
			if speed < 1 then
				rotate = 0
			end
			
			y = y + math.rad(rotate)
			
			speed = (settings.Gaits[gait].Speed*15) / (15+math.abs(rotate))
			
			if gait >= 3 then
				speed = speed * horse.Speed.Value
			end
			
			speed = (speed + horse.HumanoidRootPart.BodyVelocity.Velocity.magnitude*9)/10
			
			local dir =(CFrame.Angles(0,y,0)*CFrame.new(0,0,1)).p
			
			horse.HumanoidRootPart.BodyVelocity.Velocity = dir * speed
			horse.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(),dir) + horse.HumanoidRootPart.Position
			
			
			wait()
		end
		
		sitAnim:Stop()
		player.Character.Humanoid.AutoRotate = true
	end
		end
	end
	end
What does this script do?

For people curious about why I am trying to call Network Ownership API on anchored parts in the first place, well here is why.

Basically I have this Horse system where you can get a Horse Spawner Tool and spawn a horse and ride it, and it was originally scripted by my friend who made it so only people who spawned the horse could ride it but he didn’t give me the full system so people can still ride horses that other players spawn. I don’t know if there is any code in there that I don’t need to keep but if anyone sees something that would be better if I take it out please let me know!

7 Likes

The error is a literal statement. You are unable to set the network ownership of anchored parts or parts welded to anchored parts. I assume this is because there’s no physics being applied to those parts, so there’s no reason for them to have their network ownership set. I believe it’s automatically set to the server, you’ll have to You can check using BasePart::GetNetworkOwner.

There are various functions in BaseParts related to network ownership that you can use to your advantage, such as BasePart::CanSetNetworkOwnership. You can use this to check if you can set the part’s network owner first before actually setting it to avoid errors.

Also see the article on Network Ownership.

10 Likes

Basically I need to unanchor the assembly?

I will try this solution and get back to you.

And if it works I will mark your answer as the solution.

Thanks for responding!

3 Likes

Honestly, I have no idea. I’ve never had an instance in which I need to use any network ownership APIs except for one time where I lazily coded a bow and arrow with the arrow part’s network owner being the server.

3 Likes