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

Can someone help me with my Anti-Cheat because I don't want exploiters in my game?

Can someone help me make a script where if you touch a brick you're character get's deleted, for an example: *someone glitch out of map then if touch the part then they get deleted and they won't be able to play unless they rejoin?

1 comment

0

Just enable FilteringEnabled and then learn how to use it. There are tutorials online

2 answers

✓ Accepted answer

A better way to do this is to either :Kick() them from the game or :Remove.

Kicking them from the game is just kicking them. Removing them from the game, freezes their camera deletes their player from the player list and gets rid of their player AND gives no warning.

I'd say it would go like this:

local part = script.Parent

local function Touch(something)

if something.Parent:FindFirstChild('Humanoid') =~ nil then 
local character = something
local player = game.Players:GetPlayerFromCharacter(character)


part.Touched:connect(Touch)

So with Kick() you can give them a warning like:

local part = script.Parent

local function Touch(something)

if something.Parent:FindFirstChild('Humanoid') =~ nil then 
local character = something
local player = game.Players:GetPlayerFromCharacter(character)

player:Kick('Stop Cheating!')

part.Touched:connect(Touch)

Or just put player:Remove() in place of `player:Kick('Stop Cheating!')' although it is deprecated.

You can check the wiki for more about TouchedEvents, Kick and Remove.

Use the Touched event to remove their character

workspace.Part.Touched:Connrct(function(hit)
    local plr = hit.Parent.ClassName == "Model" and hit.Parent:FindFirstChildOfClass("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent)
    if not plr then return end
    plr.Character = nil --remove their character
end)

Just make sure not to LoadCharacter() on them afterwards.

1 comment

0

There is a problem, you forgot to check the script again, you typed " workspace.Part.Touched:ConnRct(function(hit)

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