|
| 17 Sep 2012 09:10 PM |
This script is supposed to change the victims materials when said. It errors and gives me a stupid error when done.
Output:
Line 50: bad argument #1 to 'pairs' (table expected, got userdata) LINE 50 IS POINTED OUT IN SCRIPT
Script:
Players = game:GetService("Players") StarterGui = game:GetService("StarterGui") GamePass = game:GetService("GamePassService")
--Table stuff local admins = {"thedeathmaster01"} local commands = {"wood/Player -- Changes Players body parts to wood", "slate/Player -- Changes Players body parts to slate", "ice/Player -- changes Players body parts to ice", "grass/Player -- changes Players body parts to grass", "foil/Player -- changes Players body parts to foil", "concrete/Player -- changes Players body parts to concrete", "corrmetal/Player -- changes Players body parts to Corroded Metal", "dplate/Player -- changes Players body parts to Diamond Plate"}
game.Players.PlayerAdded:connect(function(player) if GamePass:PlayerHasPass(player,93017980) then --Adding admins until line 13 table.insert(admins, player.Name) end player.Chatted:connect(function(msg) --Start admin script for i = 1, #admins do if player.Name == admins[i] then
function findPlayer(name) --start find player function for _, player in pairs(game.Players:GetPlayers()) do if player.Name:lower():find(name:lower()) then return player end end end
--start commands command if msg == "commands" then cmds = Instance.new("Hint", player.PlayerGui) cmds.Name = "commandlist" for i = 1, #commands do cmds.Text = commands[i] wait(2) end player.PlayerGui.commandlist:Destroy() end --end commands command
--start Concrete change command if msg:sub(1,9) == "concrete/" then con = findPlayer(msg:sub(10)) for _,v in pairs(con.Character:GetChildren()) do if v:IsA("Part") then v.Material = "Concrete" end end end --end concrete command
(UNDER THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!) --start corrmetal command if msg:sub(1, 10) == "corrmetal/" then victim = findPlayer(msg:sub(11)) for _,v in pairs(victim.Character) do --LINE 50 IS RIGHT HERE@!!!!!!! if v:IsA("Part") then v.Material = "CorrodedMetal" end end end --end corrmetalcommand (ABOVE THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
--start dplate command if msg:sub(1,7) == "dplate/" then dpl = findPlayer(msg:sub(8)) for _,v in pairs(dpl.Character) do if v:IsA("Part") then v.Material = "DiamondPlate" end end end --stop dplate command
--Default ends end end end) end)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Sep 2012 09:20 PM |
for i, v in pairs(victim.Character:GetChildren()) do
¤ ¤ † K M X D † ¤ ¤
|
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 09:36 PM |
line 61 too,
for i, v in pairs(dpl.Character) do |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Sep 2012 09:38 PM |
| Well concerning you just changing a variable. '_' to 'i'. |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:14 PM |
| Why do I have to do i, v why can't I just do _? _ = i |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:17 PM |
| You don't have to. I use for _, p in pairs sometimes |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Sep 2012 11:19 PM |
But it should be like this:
for _,v in pairs(dpl.Character) do Not that, but this:
for _, v in pairs(dpl.Character:GetChildren()) do |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:19 PM |
| I guess I'll just make a table listing all the body parts then make it change everthing in that table. |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:19 PM |
| LOL stupid mistake on my end. Thanks! I sometimes do that XD |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:27 PM |
| I do that A LOT when writing. I'll forget like the last letter, and be like, "I collected the dat." |
|
|
| Report Abuse |
|
|
| |
|