TacoBowls
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 112 |
|
|
| 27 Jan 2013 02:03 AM |
Eh, I'm not sure what exactly I did wrong. The problem is, the script is only working when their is only one possible command. If I add any others, the script breaks.
Heres a small portion of the script:
local derp = {["TacoBowls"] = true} banned = {"Player"}
function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end function onChatted(message, player) if message:sub(1, 4) == "!ban" and derp[player.Name] then victim = findPlayer(message:sub(5)) victim:Destroy() end table.insert(banned, victim.Name) end
if message:sub(1, 5) == "!kill" and derp[player.Name] then victim = findPlayer(message:sub(6)) victim.Character:BreakJoints() end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end)
So if I get rid of the kill command, it will work. Or if I get rid of the ban command, the kill will work. But not both together..
Thanks for any help. |
|
|
| Report Abuse |
|
|
CokeCody
|
  |
| Joined: 31 Mar 2010 |
| Total Posts: 394 |
|
|
| 27 Jan 2013 02:08 AM |
Instead of having a bunch of if statements and ends, just use elseif. Like:
Game.Players.PlayerAdded:connect(function(player) if player.Name == "CokeCody" or player.Name == "TacoBowls" then player.Chatted:connect(function(chat) msg = chat:lower() if msg == "kill" then --Code that I don't feel like thinking about elseif msg == "kick" then --More code I don't feel like thinking about elseif msg == "msg" then --And some more code end end) end end)
--This is just for help, you don't need to use my way. |
|
|
| Report Abuse |
|
|
TacoBowls
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 112 |
|
|
| 27 Jan 2013 10:22 AM |
Bump^ Not sure if that really solved my problem though. |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2013 10:41 AM |
| that should have fixed it... |
|
|
| Report Abuse |
|
|
TacoBowls
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 112 |
|
|
| 27 Jan 2013 10:58 AM |
Well, I had to change parts of it and use strings instead, this is what I got after doing so:
banned = {} Game.Players.PlayerAdded:connect(function(player) if player.Name == "CokeCody" or player.Name == "TacoBowls" then player.Chatted:connect(function(chat) if string.sub(1, 4) == "ban/" then victim = findPlayer(string.sub(5)) victim:Destroy() table.insert(banned, victim.Name) elseif string.sub(1, 5) == "kill/" then victim = findPlayer(string.sub(6)) victim.Character:BreakJoints() end end) end end)
Well, that doesn't work at least. Although, I've never actually done it that way either, so it's probably something I did. Do you see what's wrong here? |
|
|
| Report Abuse |
|
|
CokeCody
|
  |
| Joined: 31 Mar 2010 |
| Total Posts: 394 |
|
|
| 27 Jan 2013 01:35 PM |
"victim = findPlayer(string.sub(5))"
What is "findPlayer"? |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2013 01:37 PM |
function findPlayer(string) for _,v in pairs(game:GetService'Players':GetPlayers'')do if v.Name:lower'':sub(1,string:len'')==string:lower'' then return v end end end |
|
|
| Report Abuse |
|
|
TacoBowls
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 112 |
|
|
| 27 Jan 2013 01:38 PM |
Derp, I forgot that I took away the function findPlayer I had inserted in the first script.
Thanks for all the help! |
|
|
| Report Abuse |
|
|