Hello,
I’m trying a ping-pong script, so that I can check if my client anti-cheat is disabled or not. When disabled, it errors with “Script that implemented this callback has been destroyed while calling async callback”. How do I prevent it from erroring and just kicks the player when it’s destroyed instead?
-- Server
local Remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes");
game:GetService("Players").PlayerAdded:Connect(function(Player)
local PingPong = coroutine.create(function()
while true do
wait(5);
local Ping = Remotes.PingPongEvent:InvokeClient(Player);
if not Ping then
Player:Kick("Ping-pong event broken.");
end;
end;
end);
coroutine.resume(PingPong);
end);
-- Client
local Remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes");
Remotes.PingPongEvent.OnClientInvoke = function()
return true;
end;