Cheat automatic ban

  1. What do you want to achieve?
    Speed too fast will be permanently banned

  2. What is the issue?
    kicked but not permanently banned

StarterPlayer StarterPlayerScript’s localscirpt

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
repeat wait() until LocalPlayer.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local localplayeruid = LocalPlayer.UserId

while true do
    wait()
	if LocalPlayer.Character.Humanoid.WalkSpeed >= game.StarterPlayer.CharacterWalkSpeed+1 then
		bandatabase:FireServer(LocalPlayer)
		LocalPlayer:Kick("you are banned")
        wait(10)
    end
end

ServerScriptService’s scirpt

local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local datastoreservervice = game:GetService("DataStoreService")
local bandatastore = datastoreservervice:GetDataStore("bandatastore")
local Player = game:GetService("Players")

bandatabase.OnServerEvent:Connect(function()	
	local success, errormessage = pcall(function()
		bandatastore:SetAsync(Player.UserId, true)
	end)
end)

ServerScriptService’s scirpt

local datastoreservervice = game:GetService("DataStoreService")
local bandatastore = datastoreservervice:GetDataStore("bandatastore")

game.Players.PlayerAdded:Connect(function(player)
	local playerUserId = player.UserId

	local banned
	local success, errormessage = pcall(function()
		banned = bandatastore:GetAsync(playerUserId)
	end)
	
	if banned == true then
		player:Kick("(ID:C1)\n\nYou have been banned if this is a bug please report it to the Staff")
	end
end)
3 Likes

Rename the variable from Player to Players

Put Player inbetween the brackets, like so

bandatabase.OnServerEvent:Connect(function(Player)

Remove LocalPlayer.

Also, I just want to say, this is very easily bypassable. I suggest you read up on this fantastic post, if you’re looking to make a good anti-cheat:

And this:

4 Likes

Changing the names of variables might be helpful but I don’t think its the problem. I think its a data store issue. Whats is your output kerjinhom?

Read the scripts, he’s made a variable called Player which is set to game:GetService("Players"), and then tries to use Player.UserId on that.

1 Like

Oh yea, my bad. He is treating it like a local script.

the problem still exists

local Player = game:GetService("Players")
local LocalPlayer = Player.LocalPlayer
repeat wait() until LocalPlayer.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local localplayeruid = LocalPlayer.UserId

while true do
	wait()
	if LocalPlayer.Character.Humanoid.WalkSpeed >= game.StarterPlayer.CharacterWalkSpeed+1 then
		bandatabase:FireServer()
		LocalPlayer:Kick("you are banned")
		wait(10)
	end
end

I think the problem is here But I tried for hours and still didn’t solve the problem

local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local datastoreservervice = game:GetService("DataStoreService")
local bandatastore = datastoreservervice:GetDataStore("bandatastore")
local Player = game:GetService("Players")

bandatabase.OnServerEvent:Connect(function(Player)
	local success, errormessage = pcall(function()
		bandatastore:SetAsync(Player.UserId, true)
	end)
end) 

Have you tried renaming Player to Players here like I said? Are there any errors?

I have tried but it still doesn’t work

local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local datastoreservervice = game:GetService("DataStoreService")
local bandatastore = datastoreservervice:GetDataStore("bandatastore")
local Players = game:GetService("Players")

bandatabase.OnServerEvent:Connect(function(Player)
	local success, errormessage = pcall(function()
		bandatastore:SetAsync(Player.UserId, true)
	end)
end) 
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
repeat wait() until LocalPlayer.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local localplayeruid = LocalPlayer.UserId

while true do
	wait()
	if LocalPlayer.Character.Humanoid.WalkSpeed >= game.StarterPlayer.CharacterWalkSpeed+1 then
		bandatabase:FireServer()
		LocalPlayer:Kick("you are banned")
		wait(10)
	end
end

But the only error is this

Why haven’t you renamed Player to Players in

local Player = game:GetService("Players")

in the image?

I’m sorry I took the wrong screenshot but this causes the script to not work


You need to change

local LocalPlayer = Player.LocalPlayer

to

local LocalPlayer = Players.LocalPlayer

as well

it still doesn’t work

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
repeat wait() until LocalPlayer.Character
local replicatedstorage = game:GetService("ReplicatedStorage")
local bandatabase = replicatedstorage:WaitForChild("CheatBan")
local localplayeruid = LocalPlayer.UserId

while true do
	wait()
	if LocalPlayer.Character.Humanoid.WalkSpeed >= game.StarterPlayer.CharacterWalkSpeed+1 then
		bandatabase:FireServer()
		LocalPlayer:Kick("you are banned")
		wait(10)
	end
end

I am using RemoteEvent I’ll try to replace it with RemoteFunction later

--LOCAL

local starterPlayer = game:GetService("StarterPlayer")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")

humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
	if humanoid.WalkSpeed > starterPlayer.CharacterWalkSpeed then
		remote:FireServer()
	end
end)
--SERVER

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.RemoteEvent

remote.OnServerEvent:Connect(function(player)
	player:Kick()
end)

This is working on my end, a single RemoteEvent instance is used and has been placed inside the ReplicatedStorage container.

image

1 Like

Hello! I suggest reading a guide on making a proper anti-exploit as this can be easily bypassed by exploiters.

1 Like

good news after a bit of tinkering, I found the root cause was because it was kick too fast can’t upload to the database

2 Likes

:slight_smile: Well done. I suggest you mark this as solution so people know its been sorted :exclamation: