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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Can you please explain this to me?

Previous Thread :: Next Thread 
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
03 Aug 2015 03:45 AM
ocal wantplay = {}

repeat
wait()
for i, v in pairs(game.Players:GetPlayers()) do
if v.PlayerStats then
if v.PlayerStats.ingame.Value == true then
table.insert(wantplay, v)
end

end
end
break

until nil

local sherrif = wantplay[math.random(1, #wantplay)]
local murderer = wantplay[math.random(1, #wantplay)]

while sherrif.Name == murderer.Name do
wait()
local sherrif = wantplay[math.random(1, #wantplay)]
end

local chosen1 = game.Players:FindFirstChild(murderer.Name)
local chosen2 = game.Players:FindFirstChild(sherrif.Name)

chosen1.PlayerStats.murderer.Value = true
chosen2.PlayerStats.sherrif.Value = true

table.remove(wantplay)

explain why it works the FIRST time but gives up the 3nd time!
Report Abuse
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
03 Aug 2015 03:46 AM
(BTW there is a local on the top line, i just forgot to paste it) (That is replaceing ocal, its local not ocal in the code)
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
03 Aug 2015 07:14 AM
local wantplay = {}
wait()
for i, v in pairs(game.Players:GetPlayers()) do
if v.PlayerStats and v.PlayerStats.ingame.Value then
table.insert(wantplay, v)
end
end
local sherrif,murderer = wantplay[math.random(#wantplay)],nil
repeat
murderer = wantplay[math.random(#wantplay)]
until murderer~=sherrif
murderer.PlayerStats.murderer.Value = true
sherrif.PlayerStats.sherrif.Value = true
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