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: Broken SB Commands

Previous Thread :: Next Thread 
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 03:25 PM
I had started creating commands, today, and I have been constantly testing it. Below are the vital parts.
When I use the ":kill" command, it works fine, but when I use the ":ban" command, it errors, and the script breaks. I don't know why this is, however.

----------

commands = {
["kill"] = function(player)
if (player.Character) then
player.Character:BreakJoints();
end;
end;

["ban"] = function(player)
players[player.Name] = 0;
player:Destroy();
end;
};

----------

function findPlayer(pattern)
local list = {}

for _, v in pairs(game.Players:GetPlayers()) do
if (string.find(v.Name:lower(), pattern:lower())) then
table.insert(list, v);
end;
end;

if (#list ~= 0) then
return list;
end;
end;

----------

function onCmd(msg, spkr)
if (string.sub(msg:lower(), 1, 6) == ":kill ") and (players[spkr.Name] > 1) then
local list = findPlayer(msg:sub(7));

for _, v in pairs(list) do
commands.kill(v);
end;
elseif (string.sub(msg:lower(), 1, 5) == ":ban ") and (players[spkr.Name] > 2) then
local list = findPlayers(msg:sub(6));

for _, v in pairs(list) do
commands.ban(v);
end;
end;
end;
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
11 May 2013 03:28 PM
I'm pretty sure you didn't define players
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 03:30 PM
I did, and I also noted that it broke at the command ":ban" instead of not working all together.
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 03:42 PM
Bump
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 03:56 PM
Bump...?
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
11 May 2013 03:58 PM
Where did you define the players table???
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 04:00 PM
I thought it wasn't vital (which, it really isn't), so I didn't add it.


players = {["Shoqwave"] = 4, ["Player2"] = 0}
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
11 May 2013 04:03 PM
It is vital, as if you try putting that into the command line, it doesn't work

14:02:48.327 - players["string"] = 1:1: attempt to index global 'players' (a nil value)
14:02:48.328 - Script "players["string"] = 1", Line 1
14:02:48.329 - stack end
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 04:05 PM
Looks non-vital to me.

array = {}
array["Test"] = 1
print(array["Test"])
Report Abuse
Shoqwave is not online. Shoqwave
Joined: 13 May 2012
Total Posts: 215
11 May 2013 04:15 PM
Thank you for literally no help.
I figured out the problem, it was a simple typo, and had nothing to do with the non-vital table.
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
11 May 2013 04:17 PM
I was the only one who tried to help, sorry for the attempt
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