Part's position isn't accurate until I switch from server back to client in Roblox studio playtest

I’m trying to implement raycast hit detection into the gun that I’m currently making. The raycast starts at the muzzle position of the gun & goes in the direction of the player’s mouse.hit.Position. The problem is that the muzzle position isn’t accurate

…until I switch from server then back to the client, as shown in this video:

What’s being printed in the output is the Y value of the muzzle part’s position.

Some things to take not of is that the muzzle part is a descendant of CurrentCamera (in the workspace) and only exists on the client, as it’s a part of a viewmodel.

This is the code for getting the muzzle position:

I’ve been stumped on this for maybe about an hour, some insight would be greatly appreciated on how I can get an accurate muzzle position value!

It seems it’s taking a long time to update the muzzle part’s position because if I just sit in the game for a while, eventually it’ll start giving me an accurate muzzle position. Still don’t know how to fix/get around this

I probably didn’t explain my situation very well, which is why I didn’t get any replies, but from ChatGPT, I got my solution:

All I had to do was anchor one of the parts in my view model to make all the rest of the parts welded/motor6ded to it immune to Roblox’s physics, which I believe was causing the bug, as ChatGPT implies.

I still don’t know why before I came to this solution, switching to the server, then back to client during playtesting fixed this bug though, lol