Global autoban script

so i have this script that makes the hacker automatically get banned when they reached the finish line in less than 30 secs but the player is only banned from the server that he is in how can i make it globally

local TimeRecord = game.ReplicatedStorage.TimeRecord

script.Parent.Touched:Connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		local totalTimeValue = (TimeRecord.Minutes.Value * 60) + TimeRecord.Seconds.Value 
		local player = game.Players:GetPlayerFromCharacter(part.Parent)
		if totalTimeValue < 30 and  player.activatable.Value == true then
			player.activatable.Value = false
			local Ban = Instance.new("IntValue")
			Ban.Name = player.Name 
			Ban.Value = player.UserId
			Ban.Parent = game.ReplicatedStorage.BannedList
			player:Kick("lol Hacker")
		end
		
		if player.activatable.Value == true and totalTimeValue > 30 then
			player.activatable.Value = false
			game.ReplicatedStorage.Finsihed:FireAllClients(player)
			player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
			player.stats.currentXP.Value += 25 * player.xpMultiplier.Value
			player.Money.Cash.Value = player.Money.Cash.Value + 25 * player.Multiplier.Value
			game.ReplicatedStorage.CoinIndicator.Sixth:FireClient(player)
			if player.PlayerStats.BestTime.Value == 0 or player.PlayerStats.BestTime.Value > totalTimeValue then
				player.PlayerStats.BestTime.Value = totalTimeValue
			end
			
			
		end
	end
end)

You can use Data Stores to save bans across all servers.

can you save instance in datastores?

No, you can save UserIds, which are integers.

1 Like

can you send me a sample on how to save integers on data stores because i only used it on leaderstats

You do the exact same thing you’re already doing. Its likely your leader stat values are also integers. Integers are just whole numbers.

1 is an integer
5215 is an integer
1.234 is not an integer

1 Like
game.Players.PlayerAdded:Connect(function(plr)
	if plr.PlayerStats.banned.Value == true then
		plr:Kick("Banned reason: Hacking/Exploiting")
	end
end)

i just did this its much simpler

why does it not kick me my banned value is true
but

Did you set it after you joined?

i did a while loop and it banned me now but how can i unban myself? rip

Well, did you save the ban to a data store or not? If not, you should be able to just join back.

it is saved in the data stores that’s why i cant unban my self i think ill just add an exception to the banned script

To add on to this, make sure api services are enabled so data store service works.

You can run RemoveAsync in the command bar on the key where you saved your ban as.

2 Likes

Try using a different data store, it’s way more simpler then doing that. The only downside is if someone else recently got banned.

1 Like