Hello, I’m trying to make a anticheat that basically bullies exploiters.
I want to figure out how to make a sort of script that prevents exploiters from attempting to respawn in the game.
Here is a sample from infinite yield’s respawn command function.
function respawn(plr)
if invisRunning then TurnVisible() end
local char = plr.Character
if char:FindFirstChildOfClass("Humanoid") then char:FindFirstChildOfClass("Humanoid"):ChangeState(15) end
char:ClearAllChildren()
local newChar = Instance.new("Model")
newChar.Parent = workspace
plr.Character = newChar
wait()
plr.Character = char
newChar:Destroy()
end
I know some other developers have an anticheat to prevent respawn hacks, especially the ones made by Infinite Yield.
This seems to be a very circumstantial problem, why exactly would you want to prevent forceful respawning when players can just reset to respawn?
If you look in that respawn function, you can see that it clears all the children of character. Because the client has network ownership over their character, if they remove their humanoid it will replicate.
Watching to make sure people do not remove their humanoid from their characters is able to be done serverside and will prevent more than just this. (Other forms of godding themselves, etc)
Solution:
In other words, you can watch anytime a child is removed from their character, and if it is a humanoid, you can rightfully assume they are exploiting. (As long as nothing else in your game removes a players humanoid)
A script located in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.ChildRemoved:Connect(function(child)
if child:IsA("Humanoid") then
warn(player.Name .. " is attempting to remove a humanoid from their character!")
player:Kick()
end
end)
end)
end)
The main thing is one: usually exploiters will make invis scripts similar to how respawn scripts work. I want to prevent it happening in-game, so exploiters cannot “sneak attack” on people with using exploits.
I thought you asked about how to make an anti-respawn script, as the title suggests? I provided the sample code to do just that based on the function you provided.