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
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table error

Previous Thread :: Next Thread 
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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 is not online. 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
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
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
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
18 Oct 2012 08:18 PM
REMEMBER, THE SCRIPT DOES WORK MOSTLY

It KICKS the Player, but does NOT BAN Them.
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