I’m trying to make a ServerSided AntiCheat, but there is one problem, the Changed event is only firing once, and that’s only when my Character spawns. Couldn’t find anybody else having the same problem.
It only prints “HumanoidRootPart Position Changed” once.
Code
local Character = script.Parent
if Character then
print("Character Added")
end
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
print("HumanoidRootPart Found")
HumanoidRootPart.Changed:Connect(function(Property)
if Property == "Position" then
print("HumanoidRootPart Position Changed")
end
end)
Yes I’ve tried GetPropertyChangedSignal, does the same thing.
Honestly, Changed has a history of being pretty inconsistent for me. I’ve run into this same exact issue when trying to make an anti-cheat for speed hacking.
My solution was to store everyone’s current positions and check for updates constantly through a loop.
local Players = game:GetService("Players")
local playerPosition = {} -- Dictionary
Players.PlayerAdded:Connect(function(player)
while player ~= nil do
local character = player.Character
if not character then
character = player.CharacterAdded:wait()
end
if playerPosition[player.Name] == nil then
playerPosition[player.Name] = character.HumanoidRootPart.Position
else
if character.HumanoidRootPart.Position ~= playerPosition[player.Name] then
playerPosition[player.Name] = character.HumanoidRootPart.Position
print("Position for " .. player.Name .. " changed!")
end
end
wait()
end
playerPosition[player.Name] = nil -- remove upon leaving
end)