Can part change events be used in localscripts?

I want to run a function after the PrimaryPart of the LocalPlayer’s character’s CFrame is updated, here’s what I wrote:

local chr = game.Players.LocalPlayer.Character

local function updateMapPos()
    --stuff happens here
end

chr.PrimaryPart:GetPropertyChangedSignal("CFrame"):Connect(updateMapPos)

No matter what I do this event is never triggered, I tried to check for the primarypart position but that also didn’t work. Does that just not work on localscripts??

Yes, this is expected, CFrame changed signals don’t fire when the CFrame is updated via physics. Moving your character around constitutes it being changed by physics. You’d need to read the CFrame every frame (ie listen to a RunService event or use :BindToRenderStep) to get your intended result.

To answer the question in the title, the CFrame changed signal will fire when the part is not updated via physics (when the .Position/CFrame is manually set)

1 Like

I see, so I should just use RunService to get an updating character position?

Yep, you’d just read from the .CFrame property every frame

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.