|
| 29 Aug 2013 09:16 AM |
How do I do it?
Like they enter the game, but if they are banned from it, they will die. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 29 Aug 2013 09:37 AM |
game.Players.PlayerAdded:connect(function(player) if player.Name == "Bannedplayernamehere" or player.Name == "Bannedplayer2namehere" then while wait() do player.Character.Humanoid.Health = 0 end end end)
you can put as many "or player.Name == "bannedplayernamehere""s as you would like. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 29 Aug 2013 09:53 AM |
You should save the banned players in a table, and then have a table iterate through them rather than using the "or" opperator. You should also be waiting until the character exists. The player could be there when the character isn't.
These are just two little issues the code above has. |
|
|
| Report Abuse |
|
|
| |
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 29 Aug 2013 04:38 PM |
Kodran's would potentially error, here's a better version.
local banned = {'name1', 'name2'} local function loopkill(plr) plr.CharacterAdded:connect(function(char) coroutine.resume(coroutine.create(function() repeat pcall(function() char:BreakJoints() end) until char.Humanoid.Health <= 0 end)) end) local function checkBanned(plr) for _, v in pairs(banned) do if plr.Name:lower() == v:lower() then return true end end end local function PlayerEntered(plr) if checkBanned(plr) then loopkill(plr) end end Game.Players.PlayerAdded:connect(PlayerEntered)
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|