|
| 15 Oct 2012 09:25 PM |
Idk, somehow this ain't working, I THINK it's with the Table. Help?
------------
banned = {"Player1","Player2","Noob"}
function Ban(p) table.insert(banned,p.Name) p:Destroy() end
--[Few hundred lines of other STuff that works fine, part of which calls the "Ban()" function]
game.Players.PlayerAdded:connect(function(ply) for i = 1,#banned do if banned[i]:lower()==ply.Name:lower() then ply:Destroy() end end end)
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 15 Oct 2012 09:30 PM |
function Ban(p) table.insert(banned,p.Name) p:Destroy() end
How are you calling this function? With a connection line or just calling it as a normal function?
Ban("miz656")
When you call this and run it, you can Destroy() me because I'm not part of the game.
That's the only error I can possibly see at the moment.
|
|
|
| Report Abuse |
|
|
|
| 18 Oct 2012 05:31 PM |
I basically do...
Ban(game.Players[ply])
Note that it Removes the Player, but They can re-join. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Oct 2012 06:40 PM |
Add a .PlayerEnetered:
game.Players.PlayerEnetered:connect(function(Player) for i, v in pairs(Banned) do if v == Player.Name then Player:Destroy() end end end) |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 18 Oct 2012 06:59 PM |
PlayerEntered is not an event, PlayerAdded is.
Your function will work, but p must be a player, not a text. Your calling line looks fine, just be sure it's a player. |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 18 Oct 2012 07:02 PM |
Wait... is ply a string or an object?
Ban(game.Players[tostring(ply)])
tostring() turns w/e is in the parentheses into a string. If it's an object, it becomes a string of the object's name. If it's an int, bool, or even already a string, it will do something like this
x = true x = tostring(x) -- "true" |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Oct 2012 07:47 PM |
THIS IS ALL YOU WILL NEED:
local Banned = {}
function IsBanned(Player) for i, v in pairs(Banned) do if v == Player.Name then return true end end return false end
function Ban(Player) if Player == nil or Player.Parent == nil then return false end if IsBanned(Player) then return false end table.insert(Banned, Player.Name) return true end
game.Players.PlayerAdded:connect(function(Player) if IsBanned(Player) then Player:Destroy() end end |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2012 08:17 PM |
Within the Script, It checks to make sure Player Exists,
SelectedPly = textbox.Text ply = game.Players:findFirstChild(SelectedPly) if ply ~= nil then --stuff |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2012 08:18 PM |
REMEMBER, THE SCRIPT DOES WORK MOSTLY
It KICKS the Player, but does NOT BAN Them. |
|
|
| Report Abuse |
|
|