Network Ownership API error even though none of the parts are anchored

Hi, so im making a game inspired by dead rails, when I finished scripting the train this error popped up,

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

but none of the attachment’s parts (attachment parent which is a base part) are anchored, I probably think its the script,

Script
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local tracks  = workspace.Tracks
local train = game.Workspace.Train
local seat = train.Seat
local engine = train.engine
local prismatic = engine.PrismaticConstraint
local client = train.client
local remote =  client.train
local target =  tracks.Track1.Track.target

local Speed = 35
local current = 1
local driver = nil

engine:SetNetworkOwner(nil)

RunService.Heartbeat:Connect(function(delta)
	local track = tracks:FindFirstChild("Track"..current)
	local next  = tracks:FindFirstChild("Track"..current + 1)
	
	local progress = prismatic.CurrentPosition / track.PrimaryPart.Size.Z
	
	if progress > 0.99 and next then
		current += 1
		target.WorldCFrame = next.PrimaryPart.trailattach.WorldCFrame
		prismatic.LowerLimit = 0
	else
		target.WorldCFrame = track.PrimaryPart.trailattach.WorldCFrame
		prismatic.LowerLimit = prismatic.CurrentPosition
	end
end)

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if not seat.Occupant then
		driver = nil
		return
	end
	
	local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
	if not player then return end
		
		driver = player
end)

remote.OnServerEvent:Connect(function(player, throttle)
	if player ~= driver then return end
	prismatic.Velocity =  math.clamp(throttle, -1, 1)  * Speed
end)

im pretty sure its to do with the engine.If the engine is not anchored like you mentioned you have no anchored parts then it shouldnt error. but it may be anchored to error since your setting networkownership

Well, the error means what it means.

Try checking with this

local function ReturnAnchoredConnectedParts(Part:BasePart)
	local Anchored = {}
	
	for _,v in Part:GetConnectedParts() do
		if v.Anchored then
			table.insert(Anchored, v)
		end
	end
	
	return Anchored
end

print(ReturnAnchoredConnectedParts(engine))

Your new script, featuring the debug features:
See what it prints.

local function ReturnAnchoredConnectedParts(Part:BasePart)
	local Anchored = {}
	
	for _,v in Part:GetConnectedParts() do
		if v.Anchored then
			table.insert(Anchored, v)
		end
	end
	
	return Anchored
end

print(ReturnAnchoredConnectedParts(engine))

---

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local tracks  = workspace.Tracks
local train = game.Workspace.Train
local seat = train.Seat
local engine = train.engine
local prismatic = engine.PrismaticConstraint
local client = train.client
local remote =  client.train
local target =  tracks.Track1.Track.target

local Speed = 35
local current = 1
local driver = nil

print(ReturnAnchoredConnectedParts(engine))

engine:SetNetworkOwner(nil)

RunService.Heartbeat:Connect(function(delta)
	local track = tracks:FindFirstChild("Track"..current)
	local next  = tracks:FindFirstChild("Track"..current + 1)

	local progress = prismatic.CurrentPosition / track.PrimaryPart.Size.Z

	if progress > 0.99 and next then
		current += 1
		target.WorldCFrame = next.PrimaryPart.trailattach.WorldCFrame
		prismatic.LowerLimit = 0
	else
		target.WorldCFrame = track.PrimaryPart.trailattach.WorldCFrame
		prismatic.LowerLimit = prismatic.CurrentPosition
	end
end)

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if not seat.Occupant then
		driver = nil
		return
	end

	local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
	if not player then return end

	driver = player
end)

remote.OnServerEvent:Connect(function(player, throttle)
	if player ~= driver then return end
	prismatic.Velocity =  math.clamp(throttle, -1, 1)  * Speed
end)
1 Like

You’re trying to give the server ownership of the engine, but if any part of the train or what it’s connected to is anchored, it won’t work.