:GetPropertyChangedSignal() not Working

So I’m trying to make a script where so that whenever the player goes above or below a certain point, he gets teleported to spawn.

I use GetPropertyChangedSignal(), but it doesn’t seem to run the event. Here is my code:

local plrs = game:GetService('Players')
--torso.CFrame = workspace:WaitForChild('MainSpawnTele').CFrame
local pos = CFrame.new(-141, 10.1000004, -18.9999962,0,0,-1,0,1,0,1,0,0)

plrs.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local torso = char:WaitForChild('LowerTorso') --the reason I don't check bodytype is because I have only r15 enabled
		print('Character added!') --prints
		torso:GetPropertyChangedSignal('Position'):Connect(function()
			print(torso.Position) --doesn't print
			if torso.Position.Y < -300 or torso.Position.Y > 3000 then
				torso.CFrame = pos
			end
		end)
	end)
end)

The “Character added!” prints, but not the position. From this I have concluded that I have done something wrong within the GetPropertyChangedSignal() event. Also, I get no errors or warnings from this script.

1 Like

Changed signal doesn’t fire for Position unless it is manually set, you sadly have to poll for it yourself. The same for CFrame, Orientation, and Velocity.

4 Likes

Firing :GetPropertyChangedSignal too many times causes it to just stop and breaks.
That’s what’s been happening on my side when I use it for position that changed oftem.

I used a debounce but it still didn’t work. I then changed LowerTorso to HumanoidRootPart, but it then it worked but only once.

What do you mean by “poll”?

The opposite of what you’re doing now; instead of letting the engine tell you that the property changed, you have to check for it yourself by loop.

That’s what I had before, but someone told me that was bad writing. I forgot the exact word for that saying

If you can find a way to use signals, it is generally better to do so. For this scenario you have no choice, but you can be smart about it.

It seems like you are just checking if a player falls below -300 studs, you can wait longer if they are further away and get more aggressive as they approach this point; or you could just check infrequently instead of 30-60 times per second. I would say unless you got good reason (maybe they somehow teleport, or get flung often), you shouldn’t be checking more than once a second.

Well I guess I’ll just put it back to the way I had it. It just checks the position every tenth-second.

local plrs = game:GetService('Players')
--torso.CFrame = workspace:WaitForChild('MainSpawnTele').CFrame
local pos = CFrame.new(-141, 10.1000004, -18.9999962,0,0,-1,0,1,0,1,0,0)

plrs.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		while wait(.1) do
			local torso = char:WaitForChild('LowerTorso')
			if torso.Position.Y < -300 or torso.Position.Y > 3000 then
				torso.CFrame = pos
			end
		end
	end)
end)

Well that was a lot of “ctrl+z”-ing lol

The player might have fallen out of the world in that tenth of a second. A better way is to attach this code to RunService.Stepped in a localscript to check if the local player is falling out of the world.

You could also always hook it up using Humanoid.MoveDirection as displayed here:

local humanoid = char:WaitForChild(“Humanoid”)
humanoid:GetPropertyChangedSignal(“MoveDirection”):Connect(function()
	if torso.Position.Y < -300 or torso.Position.Y > 3000 then
		torso.CFrame = pos
	end
end)
3 Likes

For clarity I’ve been playing around with this issue and would like to point out:

an instance’s properties being changed by a tween will also fire the Changed Signal; The main indicating factor for the changed signal not firing appears to be whether the property is being controlled by Physics.

So, if you have an unanchored ball rolling, the changed signal will not fire.
If you have a humanoid being moved via the :MoveTo() method, the changed signal will not fire.

Does GetPropertyChangedSignal() works for int values?

Sorry for necro but I solved my problem using Humanoid:GetPropertyChangedSignal("MoveDirection")