Here is my code (I got rid of some stuff in the code which does not relate to the problem) :
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local Root = character:WaitForChild("HumanoidRootPart")
-----------------------------------------------------------------------------------
Root:GetPropertyChangedSignal("CFrame"):Connect(function()
print("Looping.")
end)
When I move my character, in the output there were not any ‘Looping.’ at all, why?
The code looks correct but there could be a couple of reasons why the GetPropertyChangedSignal is not firing when you move your character.
Firstly, make sure that the HumanoidRootPart of your character is being moved when you move your character. If the root part is not being moved, the CFrame property won’t change and the signal won’t fire.
Secondly, try printing the CFrame property of the HumanoidRootPart directly, outside of the signal. This will help you verify that the root part is actually being moved and that the issue is not related to the signal.
If the root part’s CFrame is being updated correctly but the signal is still not firing, you may want to try using Heartbeat instead of GetPropertyChangedSignal.
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local root = character:WaitForChild("HumanoidRootPart")
local prevPos = root.CFrame.p
game:GetService("RunService").Heartbeat:Connect(function()
local currPos = root.CFrame.p
if currPos ~= prevPos then
print("Looping.")
prevPos = currPos
end
end)
I’m not sure CFrame properties send the signal.
If you check out the Changed description in the Events section of GetPropertyChangedSignal you’ll see what I mean.
I read the documentation of the .Changed event and :GetProp signal, sadly they don’t account for physic-related changes, so I must use run service or loops to detect them. So @MrFergxl is correct.