I have a script for manually putting a player in the banlist in ROBLOX Studio, but I'm wondering how I could add people to the banlist in-game using a TextBox.
local BannedList = { ["PlayerX"] = true; ["PlayerY"] = true; ["PlayerZ"] = true; } function NewPlayer(pl) if BannedList[pl.Name] then wait() pl:Kick(); end end game.Players.PlayerAdded:connect(NewPlayer) table.foreach(game.Players:GetPlayers(), function(i,v) NewPlayer(v) end)
First thing to do is Access the players by using the method
, :GetPlayers
.
local players=game.Players:GetPlayers()
Now that only access the Players, how do we actually access a certain player? By the pairs
function.
local players=game.Players:GetPlayers() script.Parent.FocusLost:connect(function() for i,v in pairs( players ) do if script.Parent.Text==v.Name then game.Players:WaitForChild(script.Parent.Text):Kick() end end end)
The FocusedLost
event fires when the current TextBox
is unFocused(by pressing the Enter
key)
This might work;
table.insert(BannedList, #BannedList+1, TextBox.Text)
Just run that right after having gotten input from the textbox.