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 » Scripters
Home Search
 

Re: u wat roblox api m9?

Previous Thread :: Next Thread 
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
01 Mar 2015 07:52 PM
bumpsjdubfjksdgfs

3 days until my birthday
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
01 Mar 2015 07:53 PM
game.Player.NumPlayer.Value

It is probably a Value object.
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
01 Mar 2015 07:55 PM
Oh yeah... wait
i already did that, i forgot

3 days until my birthday
Report Abuse
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
01 Mar 2015 07:57 PM
I thought you could script e.e

"no you're being stupid." -General Astrochemistry
Report Abuse
mew903 is not online. mew903
Joined: 03 Aug 2008
Total Posts: 22071
01 Mar 2015 07:58 PM
Your code makes my eyes hurt
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
01 Mar 2015 07:58 PM
@blood
i honestly never had to use tables in scripting

3 days until my birthday
Report Abuse
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
01 Mar 2015 07:58 PM
^

"no you're being stupid." -General Astrochemistry
Report Abuse
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. 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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. 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 is not online. 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 is not online. IIIIIIlII
Joined: 06 Jan 2011
Total Posts: 710
01 Mar 2015 08:12 PM
OMG you march4 too?

me too
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
01 Mar 2015 08:12 PM
No, ints need values

3 days until my birthday
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Mar 2015 08:14 PM
-.-
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. 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 is not online. 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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
01 Mar 2015 08:22 PM
^
but i really didn't know wth to do

3 days until my birthday
Report Abuse
cntkillme is not online. 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 is not online. 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 is not online. 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
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
01 Mar 2015 08:25 PM
^

"no you're being stupid." -General Astrochemistry
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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