generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I'm trying to make a loopkill script

Previous Thread :: Next Thread 
Twinmill42 is not online. Twinmill42
Joined: 04 Jun 2012
Total Posts: 16785
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 is not online. 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 is not online. 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
Twinmill42 is not online. Twinmill42
Joined: 04 Jun 2012
Total Posts: 16785
29 Aug 2013 04:26 PM
Thanks
Report Abuse
Ekkoh is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image