Positions dont update?

So um I am creating a system that should tell if a user is in any parts when they move, problem. It dont tell when the user move.
this is my code to tell when the user moves and uh well it never runs

		local connect = root:GetPropertyChangedSignal('CFrame'):Connect(function()
			warn('moved')
			local InsideOf = workspace:GetPartBoundsInBox(root.Position,Vector3.new(8,8,8),params)
			warn(InsideOf)
			
			if InsideOf[1]  then
				ragdoll(false,char)
			end
		end)

“moved” is never warned in the output, after selecting the root of the players character and watching as I jump around I can see that the position value just doesnt update, so wth is going on?

:GetPropertyChangedSignal does not work with Physics-Related properties to avoid mass-firing of the event multiple times.

Instead, you should use RunService.Heartbeat or RunService.PostSimulation, and then check if the player’s old CFrame is not equal to the player’s new CFrame. If they aren’t the player moved.

		local oldPosition
		local connect = game:GetService('RunService').Heartbeat:Connect(function()
			if oldPosition ~= root.CFrame then
				oldPosition = root.CFrame
				warn('moved')
				local InsideOf = workspace:GetPartBoundsInBox(root.Position,Vector3.new(8,8,8),params)
				warn(InsideOf)
				
				if InsideOf[1]  then
					ragdoll(false,char)
				end
			end
		end)
1 Like

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