Accurate player freezing

in my game very often I anchor a player(s). By anchoring there torso. In my game however positions and orientations of the character play a huge part in the gameplay.

when I freeze players, I disable their shiftlock and anchor their rootpart. However, when frozen the players actual position and orientation is usually uncorrect (if the player was moving during the freeze) This is super annoying messing up the whole game. How can I fix this issue?

How can I properly anchor a player so that what the server sees is correct with what the client sees?

2 Likes

Just so I can make sure I understand, the server is reading a different CFrame than the client right? In that case, depending on how you have your freeze system set up, you could send a event to the server and add the player’s Y orientation to save on the server. I may have misunderstood though.

Hello, I’m not sure if this is the reason but maybe you should reset the velocity plus decrease the walkspeed and jumpspeed to zero. I hope this helps!

Okay, I think you can do this: Send the client’s CFrame to the server, so the server anchors the client’s character to the client’s CFrame.

1 Like

that was the first thing I tried using remote functions but it didnt seem to work. Im still having a dum issue of actually freezing the player from rotation and such. But even without shiftlock and firstperson rotations theres still an offset of such.

-- server
local function setPlayersAnchored(anchored)
	for _, player in pairs(getAlivePlayers()) do
		if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			player.Character.HumanoidRootPart.Anchored = anchored
			player.Character.Humanoid.WalkSpeed = if anchored then 0 else 16

			if anchored then
				player.DevEnableMouseLock = false
			else
				player.DevEnableMouseLock = true
			end

			pcall(function()				
				local Callback = Remotes.Stand:InvokeClient(player, anchored)
				if Callback then
					player.Character:PivotTo(Callback)
				end
			end)
		end
	end
end
-- local
Remotes.Stand.OnClientInvoke = function(IsAnchored)
	if not IsAnchored then
		player.Character.HumanoidRootPart.Anchored = false

		return false
	end

	if player.Character then
		player.Character.HumanoidRootPart.Anchored = true
		player.Character.HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero
	end
	
	return player.Character:GetPivot()
end

Fetch the character model’s position/orientation on the server and send that information to the client, then have the server’s actual position overwrite the client’s actual position. Alternatively, you could have the client send its position to the server and have the client’s actual position overwrite the server’s actual position.

If you wanted to freeze a player couldn’t you just set their move speed to 0… or are you talking about if they get froze in mid air