I would like to make a game that when you die you get banned so it really feels like you are dead. I have no idea how to do this and turned over to here. I've looked on the tool box and found some but they did not work. It would be very helpful if someone could help me out or if someone could point me into the right direction to find the resources I need to accomplish this.
It's pretty simple to ban a player. And even simpler to run a function when they die.
Here are 2 examples.
Example #1: Server Ban on Death
local banList = {} game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() table.insert(banList, player.Name) player:Kick() end) end) for _,v in next, banList do if player.Name == v then player:Kick("Banned from server.") end end end)
Example #2: Permanent Ban on Death
local dataStoreService = game:GetService("DataStoreService") local banData = dataStoreService:GetDataStore("BanData") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() banData:SetAsync(player.UserId, true) player:Kick() end) end) if banData:GetAsync(player.UserId) == true then player:Kick("Banned from game.") end end)
So in both examples it works pretty much the same, a player enters the game then the script waits for the character to be added. After that it waits for the humanoid in the character and when the script detects that the humanoid has died it will run the code. In Example #1, it just adds their name to a table then searches for it when they enter the game again. If found, it kicks them. But in example #2, it changes a data store value to TRUE and when it detects a new player in the game it checks if that value is true and if it is, it kicks them aswell.