Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

.Changed event does not fire all the time?

So, I am trying to make a little anti-cheat, so I came up with seeing how far they moved from the previous time they moved. This sounded like a good idea at first, but this didn't run all the time.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		wait(1)
		local lastpos = char.Head.Position
		local deb = false
		char.HumanoidRootPart.Changed:Connect(function()
			local pos = plr:DistanceFromCharacter(lastpos)
			if pos > 0.3 and not deb then --I know this sounds a little low, but trust me. You won't pass that from jumping.
				deb = true
				warn('You seem to be moving really fast at '..pos..'...')
				plr:LoadCharacter()
				return
			elseif not deb then
				deb = true
				lastpos = char.Head.Position
				deb = false
			end
		end)
	end)
end)

This detects the tiniest bit of teleportation (like 2 studs), but it does not fire when I do not teleport, nor when I set up glitchy parts with roblox's terrible physics and fly off the baseplate, but it does not run. In case you need the teleportation part I set up, it is here

game:GetService('UserInputService').InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E then
		game.Players.LocalPlayer.Character.Head.CFrame = CFrame.new(6, 5.5, 58.25)
	end
end)

So, why does the .Changed event not detect me when I walk and fly?

4 comments

0

Are there any errors?

0

could you use :GetPropertyChangedSignal()

0

Does player movement even trigger the .Changed event? I don't think it does. Afaik any movement caused by physics does not fire any events. You're probably better off listening to RunService.Heartbeat to check for player movement speed.

0

:GetPropertyChangedSignal does not trigger when I move.

1 answer

Try switching HumanoidRootPart to Torso, it worked perfectly for me.

4 comments

0

but i want it to be r15 compatible too....................................

0

its not just like "Hey this guy's security does not with with r15 lemme switch to r15!"

0

Use UpperTorso stupid nub

0

lol

This discussion is preserved as it was. New answers, comments, and votes are closed.