Part.Position not updating for some reason

I am trying to make a part stay in the middle of a moving ball without welding it because I don’t want the part to rotate while the ball rolls. I decided to make a simple script to fix the problem

-- Variables

local Character = script.Parent
local HRP = Character:WaitForChild("HumanoidRootPart")
local Ball = Character:WaitForChild("Ball")

-- Code

Ball:GetPropertyChangedSignal("Position"):Connect(function()
	HRP.Position = Vector3.new(Ball.Position)
	print (Ball.Position)
end)

For some reason it only works once before not responding again, when I click the part and try to watch its position change in properties, it doesn’t. It just stays the same as it rolls. I’m debating whether or not I have to use the RunService to detect if the ball moves or if I’m making a mistake in my code. If there is also a way to weld a part without letting it rotate with the part it welded with I could also use that too

1 Like

When the physics engine changes Position or Rotation or things like that, Changed events don’t get fired. So you will unfortunately need to resort to a while loop or a RunService event.

Makes sense, ill try running RunService and see what happens

Well it works, but the movement of the camera is very jittery and ugly (Camera is focused on the Humanoid root part) Is there a way of creating a much more smooth movement, like the same if I welded the part?

You could try RenderStepped if you weren’t already, but you might still run into problems if Ball is controlled by the server. Instead, you could try tweening the camera with RenderStepped from the old position to the new position to cut down on jitter.

I was using renderstepped with the part, but I cant use renderstepped on the camera because I want to use the default roblox humanoid camera which is orientated around the Humanoid root part. Otherwise I would have to make my own camera system which I am not very experienced in

You can actually view the source code of the default scripts and copy them to use. Go into Studio and press Play, then navigate to StarterPlayer>StarterPlayerScripts>PlayerModule>CameraModule. It and all of its children are the camera scripts. I’m not sure if that’s particularly helpful, but it is an option.

You could also try lerping HRP’s position instead, and let the camera handle itself.

if the ball is supposed to be something controlled by the player or that the player has to use then set the ball’s network owner to the player. Put a server script and when the player is added then wait for the ball to be spawned then do:

Ball:SetNetworkOwner(Player)