|
| 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 |
|
|
|
| 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
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 23 Apr 2014 05:22 PM |
| Thanks for telling us which line line 16 is. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Apr 2014 09:34 PM |
players
Into
game.Players:GetPlayers() |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 24 Apr 2014 09:47 PM |
btw line 17 is
for i,v in pairs(1, Players) do
|
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
|
| 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 |
|
|
|
| 24 Apr 2014 11:35 PM |
Lowercase the wait(). I say do that and come back. |
|
|
| Report Abuse |
|
|