Character Position Not Updating When Client Moves

I’m trying to make a door that has a selection box that appears around the keycard slot when the player gets close enough to open the door, so I’m using GetPropertyChangedSignal on the HumanoidRootPart’s Position to check if a player is close enough to a keycard slot but the player’s position only updates when I move the character on the server and I have no idea why. I couldn’t find anyone else with the same issue so I’m just asking here.

Here’s the code

--\\ vars
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")

local doorLocation = workspace:WaitForChild("doors")

local keycardSlots = {}

--\\ main
for _,v in pairs(doorLocation:GetDescendants()) do
	if v.Name == "slot" then
		table.insert(keycardSlots, v)

local lastKeycard

root:GetPropertyChangedSignal("Position"):Connect(function() --This is what I'm having issues with
	print("position changed") --This never gets printed when the client is moving
	local closestDist = 10
	local closestKeycard
	for i,v in pairs(keycardSlots) do
		local dist = (root.Position - v.Position).magnitude
		if dist <= 10 then
			print("dist is less than 10")
			if dist <= closestDist then
				print("dist is less than closest dist")
				closestDist = dist
				closestKeycard = v
				if lastKeycard ~= nil then
					lastKeycard:FindFirstChildOfClass("SelectionBox").Visible = false
					print("removed lass keycards sselectionbox")
				lastKeycard = v
				v:FindFirstChildOfClass("SelectionBox").Visible = true
				print("added new keycards selection box")

As I said before, everything prints and works just fine when I move the character on the server, but it doesn’t update the Position when I move the character on the client so nothing happens. Here is an example of what I mean

Yeah… both .Position and .CFrame will not fire on the client unless you assign a Vector3 to the .Position or CFrame to the .CFrame property manually or through script. The reason for this to me is unknown and I was in your boots once when I coded a vehicle billboard gui popup (to enter the vehicle) based on distance and ran straight into this issue.

Anyways, there are a few different methods to approach this without checking how far away the character is on position change. And one method I tried, which I recommend that you do, which I also did for the vehicle thing I referred to, is to check the distance between the character and the door based on intervals (every x seconds).

1 Like

A good way to do this is using the render stepped event.

1 Like

I would actually not recommend doing this due to it being hard on performance afterwards when OP adds plenty of those doors around their map.

Intervals are a more safe bet and you can more easily control how often per second the script should check the distance between the character and the door - especially if the player uses an ‘fps unlocker’.

Thanks, I spent over an hour trying to figure this out and couldn’t find anything.