Need help with part grabber

I have created a script that can move parts with the player’s mouse, but if the part is moved close to another player it suddenly drops. I think it has something to do with network ownership but I’m unsure how to proceed.

script:

mouse.Move:Connect(function()
	if selectedPart then
		local humanoidRootPartPosition = character.HumanoidRootPart.Position
		local rawPositionGoal = mouse.Hit.Position
		local maxDistance = 15 

		local distance = (rawPositionGoal - humanoidRootPartPosition).Magnitude
		local clampedDistance = math.clamp(distance, 0, maxDistance)

		local modifiedPositionGoal = clampedDistance * (rawPositionGoal - humanoidRootPartPosition).Unit + humanoidRootPartPosition
		
		selectedPart:WaitForChild("BodyPosition").Position = modifiedPositionGoal
	end
end)
1 Like

You need to set network ownership on the server, so once a player selects a part and moves it, it has to be logged on the server-side and the network ownership must be set there.

You can do this with remote events or remote functions

1 Like

You should set the network ownership to the player controlling the part (in a server script):

part:SetNetworkOwnership(player)

You can also set it to nil instead of a player to make it always on the server if you want to

2 Likes

I’m confused, its returning that setnetworkownership is not a valid member of the part.