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: my script wont work! help me!

Previous Thread :: Next Thread 
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
23 Apr 2014 05:20 PM
My game script wont work. it keep s returning that something is wrong with line 16.


local Positions = {CFrame.new(-262.9, 1.4, 398.1), CFrame.new(-262.9, 1.4, 231.99)}
local G = Game.Lighting
local wep = {(G.swordbro),(G.boom)}
local Heropos = {CFrame.new(37, 54.9, 230.2)}
local herowep = {(G.gunny)}
x = 0

while true do
Wait(10)
x = x + 1
print(x)
Players = Game.Players.NumPlayers
if Players < 2 then
wait(0.0000000000000000000000000001)
elseif Players > 1 then
H = Players[math.random(1, Players)]
for _,v in pairs(players) do
if v ~= H[1] then
script.Parent.Parent.Character.Torso.CFrame = Positions[math.random(1, #Positions)]
a = wep[math.random(1, #wep)]
a:clone().Parent = script.Parent.Parent.Backpack
else
script.Parent.Parent.Character.Torso.CFrame = Heropos
b = herowep
b:clone().Parent = script.Parent.Parent.Backpack
end
end
end
wait(120)
script.Parent.Parent.Character.Torso.CFrame = CFrame.new(-371, 2.0, -1094)
game.Players.LocalPlayer.Backpack:ClearAllChildren()
character = game.Players.LocalPlayer.Character
c = character:GetChildren()
for i=1, #c do
if c[i]:IsA("Tool") or c[i]:IsA("HopperBin") then
c[i]:Destroy()
end
end
end


Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
23 Apr 2014 05:22 PM
H = Players[math.random(1, #Players)] --put # before a table variable to get amount of stuff in the table
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
23 Apr 2014 05:22 PM
Thanks for telling us which line line 16 is.
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 05:22 PM
it still didnt work. :(
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 06:39 PM
bump
Report Abuse
iOffensive is not online. iOffensive
Joined: 13 Jun 2013
Total Posts: 416
24 Apr 2014 06:47 PM
H = Players[math.random(1, Players)]

It's expecting a function since that's the format it's in.

Take out players and you get

H = math.random(1, Players)
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 09:05 PM
i understand what your saying now, and it worked! but i have another error on line 17. the output says that argument #1 expected table, got nil.

not sure what that means, but here is the line of code:

for i,v in pairs(players) do
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 09:32 PM
bump
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Apr 2014 09:34 PM
players

Into

game.Players:GetPlayers()
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Apr 2014 09:36 PM
Replace
if v ~= H[1] then


With

if v ~= H then
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 09:46 PM
The output keeps saying for line 17 table expected, got number...

This is a copy of the new piece of code....

local Positions = {CFrame.new(-262.9, 1.4, 398.1), CFrame.new(-262.9, 1.4, 231.99)}
local G = Game.Lighting
local wep = {(G.swordbro),(G.boom)}
local Heropos = {CFrame.new(37, 54.9, 230.2)}
local herowep = {(G.gunny)}
x = 0

while true do
Wait(10)
x = x + 1
print(x)
Players = game.Players:GetChildren()
if #Players < 2 then
wait(0.0000000000000000000000000001)
elseif #Players > 1 then
H = math.random(1, #Players)
for i,v in pairs(1, Players) do
if v ~= H then
script.Parent.Parent.Character.Torso.CFrame = Positions[math.random(1, #Positions)]
a = wep[math.random(1, #wep)]
a:clone().Parent = script.Parent.Parent.Backpack
else
script.Parent.Parent.Character.Torso.CFrame = Heropos
b = herowep
b:clone().Parent = script.Parent.Parent.Backpack
end
end
end
wait(120)
script.Parent.Parent.Character.Torso.CFrame = CFrame.new(-371, 2.0, -1094)
game.Players.LocalPlayer.Backpack:ClearAllChildren()
character = game.Players.LocalPlayer.Character
c = character:GetChildren()
for i=1, #c do
if c[i]:IsA("Tool") or c[i]:IsA("HopperBin") then
c[i]:Destroy()
end
end
end



Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 09:47 PM
btw line 17 is

for i,v in pairs(1, Players) do
Report Abuse
lupine is not online. lupine
Joined: 24 Jun 2008
Total Posts: 3561
24 Apr 2014 09:49 PM
By the way, you shouldn't do:
wait(0.0000000000000000000000000001)
if you want the wait to be very short, simply use wait() or wait(0). Much easier, much cleaner.
Report Abuse
IMSOEPICLE is not online. IMSOEPICLE
Joined: 29 Jul 2011
Total Posts: 452
24 Apr 2014 09:50 PM
Thanks!
Report Abuse
iOffensive is not online. iOffensive
Joined: 13 Jun 2013
Total Posts: 416
24 Apr 2014 11:32 PM
Take out the 1 and the comma in that line.

It can only reference one table, and 1 isn't a table in your script (at least, not specified). The only table is players. That is, if you make it into a table.
Report Abuse
deathkiller554 is not online. deathkiller554
Joined: 26 Jul 2011
Total Posts: 201
24 Apr 2014 11:35 PM
Lowercase the wait().
I say do that and come back.
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