|
| 01 Mar 2015 07:48 PM |
why did it say "attempt to index field 'NumPlayers' (a number value) This was my script
local players = game.Players:GetPlayers() local murderer = players[math.random(1, game.Players.NumPlayers)] local sherrif = players[math.random(1, game.Players.NumPlayers)] if murderer == sherrif then -- to avoid paradoxes and 2 weapons sherrif = players[math.random(1, game.Players.NumPlayers)] end
local x = game.ServerStorage.Gun x:Clone().Parent = game.Players[sherrif].StarterGear local y = game.ServerStorage.Gun y:Clone().Parent = game.Players[sherrif].StarterGear
3 days until my birthday |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:52 PM |
bumpsjdubfjksdgfs
3 days until my birthday |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:53 PM |
game.Player.NumPlayer.Value
It is probably a Value object. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:55 PM |
Oh yeah... wait i already did that, i forgot
3 days until my birthday |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:57 PM |
I thought you could script e.e
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
|
| 01 Mar 2015 07:58 PM |
| Your code makes my eyes hurt |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:58 PM |
@blood i honestly never had to use tables in scripting
3 days until my birthday |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:58 PM |
^
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 07:59 PM |
If you've never used tables you're not a scripter
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 08:00 PM |
well ive only started them using.. what this week? i rarely use tables, i avoided them until now
3 days until my birthday |
|
|
| Report Abuse |
|
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
|
| 01 Mar 2015 08:04 PM |
If you've never used tables you're not a scripter [2]
Seriously, I was using tables/arrays my FIRST DAY of learning Lua. But I probably learned the correct way, versus spamming this forum in order to learn |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 08:06 PM |
-- updated script local players = game.Players:GetPlayers() local murderer = players[math.random(1, game.Players.NumPlayers.Value)] local sherrif = players[math.random(1, game.Players.NumPlayers.Value)] if murderer == sherrif then -- to avoid paradoxes and 2 weapons sherrif = players[math.random(1, game.Players.NumPlayers.Value)] end
local x = game.ServerStorage.Gun x:Clone().Parent = game.Players[sherrif].StarterGear local y = game.ServerStorage.Gun y:Clone().Parent = game.Players[sherrif].StarterGear
It said NumPlayers is a number value and i couldn't use it for math.random
3 days until my birthday |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 01 Mar 2015 08:07 PM |
| Guys with the variable sheriff and murderer... Oh gawd no its ANOTHER MURDER MYSTERY GAME!!!! :O |
|
|
| Report Abuse |
|
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
|
| 01 Mar 2015 08:08 PM |
"game.Players.NumPlayers.Value"
what the heck lol, it's an int, you have to call it directly as game.Players.NumPlayers |
|
|
| Report Abuse |
|
|
IIIIIIlII
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 710 |
|
| |
|
|
| 01 Mar 2015 08:12 PM |
No, ints need values
3 days until my birthday |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 01 Mar 2015 08:14 PM |
updated the script local players = game.Players:GetPlayers() local pizza = game.Players.NumPlayers.Value local MurdererName = players[math.random(1, pizza)] local SherrifName = players[math.random(1, pizza)] if MurdererName == SherrifName then SherrifName = players[math.random(1, pizza)] end
z = game.ServerStroage.Knife:clone() z.Parent = game.Players[MurdererName].StarterGear
c = game.ServerStorage.Gun:clone() c.Parent = game.Players[SherrifName].StarterGear
3 days until my birthday |
|
|
| Report Abuse |
|
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
|
| 01 Mar 2015 08:14 PM |
Please cpmoderator, now's not the time to be an idiot
You need to do this: local murderer = players[math.random(1, game.Players.NumPlayers)]
Players.NumPlayers is a readonly integer PROPERTY. It's NOT a value. You have to call it DIRECTLY. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Mar 2015 08:19 PM |
| He's known for being a stupid troll in this forum, just ignore him/her/it. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 08:22 PM |
^ but i really didn't know wth to do
3 days until my birthday |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Mar 2015 08:23 PM |
Your original script was fine, you just put a wrong error message because you're a moron.
|
|
|
| Report Abuse |
|
|
drager980
|
  |
| Joined: 25 May 2009 |
| Total Posts: 13385 |
|
|
| 01 Mar 2015 08:24 PM |
im tired sorry for being disgusting
local players = game.Players:GetPlayers() local murderer = players[math.random(#players)] local sherrif = players[math.random(#players)] if murderer == sherrif then -- to avoid paradoxes and 2 weapons repeat sherrif = players[math.random(1, #players)] until murderer ~= sherrif end
local x = game.ServerStorage.Gun x:Clone().Parent = sherrif.StarterGear local y = game.ServerStorage.Gun y:Clone().Parent = sherrif.StarterGear
AND THE TIGER GOES ROAR |
|
|
| Report Abuse |
|
|
gerov
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 5504 |
|
|
| 01 Mar 2015 08:24 PM |
Fix your spacing.
You code is an absolute mess.
Why don't you take a seat over there? |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 08:25 PM |
^
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|