Make ban on touch part and tell the player of the ban

Hello! I’m OBC.
I am Beginner Scripter And I Don’t know how to script For a Part
mean When Player Touch that part Player will get Ban From that game And It Show Player a Gui Said You’re Got Ban!.
Please i Need Help About this
Here’s My Script But I don’t know how to make Touch = Ban

local players = (123, 1234)

local message = “You’re Failed My Challenge! Get Out Here!”

local reason = " | Reason: You’re Failed My Challenge, If You not Die or else and get Ban, Connect OBC Dsico"

game.Players.PlayerAdded:Connect(function(player)
for _, v in pairs(players) do
if player.UserId == v then
player:Kick(message,reason)
end
end
end)

Thanks You

7 Likes

There’s no point in making custom UI for this. When you call the method to kick the player, the background blurs and some CoreGUI appears telling you you’ve been kicked and for what reason. So there’s no point in making custom UI.

Also the :Kick method only has one parameter (optional), you should concatenate your reason to your initial message. Or just make both strings one string, without concatenation. Concatenation would be used if you have different reasons for the players being kicked.

6 Likes

Insert this script into the Part that will ban the Player it touch:

local Part = script.Parent --This is your Part
local Player --This is nil
local PlayerService = game:GetService("Players")
local reason = " | Reason: You’re Failed My Challenge, If You not Die or else and get Ban, Connect OBC Dsico" -- Your Banmessage

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        Player = Players:GetPlayerByCharacter(hit.Parent)
        if game:FindFirstChild(Player) then
            Player:Kick(reason)
        end
    end
end)
3 Likes

You have to use that in conjunction with a DataStore to store the banned users in it, and then when players join it checks the player ID and Kick him if its in the ban list.

1 Like

@WaterJamesPlough Yes, I knew that, it’s just that I have never used DataStore Service before. Then I read the string: and if a player loses a Challenge, it makes sense that if it is kicked out of the server, it can go back in again to try to reach the target again.

Its a event: Collisions | Documentation - Roblox Creator Hub

2 Likes

maybe you could add the player ID in a table and then save that to a DataStore.

1 Like

You would do the same as you do if you were just kicking the player. However, it will only kick the player and not ban it. To achieve this, you would need to create a table of banned players and store that table in a DataStore so whenever a player is added to the game, a script will check whether the player is in the banned list of not. If the player’s ID is in the ban list, kick the player, if not then let the player join.

1 Like

Thannk You So Much.
It’s really Work

1 Like

Thanks for your tips, but first of all I have never used the Datastore before, secondly I think that @OBCMAKEGAME didn’t mean by the ban at first, but that he meant to say kicking.

1 Like