GetPropertyChangedSignal() does not work

local CollectionService = game:GetService("CollectionService")

local function New(stair)
	print(stair)
	
	stair.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
		print("MOVE")
	end)
	
	task.spawn(function()
		while true do
			print(stair.PrimaryPart.Position)
			task.wait()
		end
	end)
end

CollectionService:GetInstanceAddedSignal("Stair"):Connect(function(stair)
	New(stair)
end)

for _, stair in CollectionService:GetTagged("Stair") do
	New(stair)
end

I’m play testing in studio (no client) and moving the stairs around, and it’s printing that the position is changing, but GetPropertyChangedSignal() never fires for it
image

2 Likes

I think the reason is that the Position property is not a direct property of an object, try :GetPropertyChangedSignal("CFrame") because the Position property is stored inside the CFrame property.

1 Like

GetPropertyChangedSignal("Position") doesn’t work unfortunately, you’ll need to use a loop to get position updates like this example:

local oldPosition = Vector3.zero

task.spawn(function()
	while true do
		if stair.PrimaryPart.Position ~= oldPosition then
			print("MOVE")

			oldPosition = stair.PrimaryPart.Position
		end

		task.wait()
	end
end)

Even GetPropertyChangedSignal("CFrame") doesn’t work for example

Edit: @NinjoOnline Also I forgot to mention, using this:

local oldPosition = stair.PrimaryPart.Position

at the top instead of this:

local oldPosition = Vector3.zero

might work closer to what you’d like since it doesn’t run until the stair changes its position from its default

1 Like

This doesn’t work either unfortunately :confused:

1 Like

Changing the Model/Parts Position with the mouse is not possible, it will not change it’s position then. Only things like TweenService or a code that modifies the position will only run the code

1 Like

Well I think it only works with strings according to my understanding of this. Position is a Vector3.

1 Like

GetPropertyChangedSignal checks for property changes. You need to input the name of the property, which is a string into the parameter.

“Position”, “BrickColor”, “Size”, “Transparency” are all strings. Their values are different values

1 Like

I’ve ran into a similar issue myself. It’s not documented, but has been mentioned by others that GetPropertyChangedSignal will not fire if the property was changed due to physics. So if you are moving the staircase by physics, no, it will not fire.

3 Likes

There are certain properties which GetPropertyChangedSignal isn’t able to be used on, this is intentional, not a bug

Position and CFrame happen to be part of the list of properties that don’t work as I explained here:

Unfortunately you’ll need to use a loop to detect change in the “Position” property

@Maelstorm_1973 I do hope it gets added as a note in the docs in the future since it would be very helpful information

2 Likes

You know, that a good idea for a documentation bug report.

3 Likes