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: Admin Erroring

Previous Thread :: Next Thread 
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
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
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Sep 2012 09:16 PM
bump
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
17 Sep 2012 09:20 PM
    for i, v in pairs(victim.Character:GetChildren()) do

¤ ¤ † K M X D † ¤ ¤
Report Abuse
evilspartan9000 is not online. evilspartan9000
Joined: 09 Apr 2010
Total Posts: 10655
17 Sep 2012 09:36 PM
line 61 too,

for i, v in pairs(dpl.Character) do
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
17 Sep 2012 09:37 PM
Nothing wrong with 61...
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
17 Sep 2012 09:38 PM
Well concerning you just changing a variable. '_' to 'i'.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Sep 2012 11:14 PM
Why do I have to do i, v why can't I just do _? _ = i
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
17 Sep 2012 11:17 PM
You don't have to. I use for _, p in pairs sometimes
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Sep 2012 11:18 PM
It still breaks :l
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
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
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
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
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Sep 2012 11:19 PM
LOL stupid mistake on my end. Thanks! I sometimes do that XD
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
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
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Sep 2012 11:28 PM
lol
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