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: ...Same order every time... math.random

Previous Thread :: Next Thread 
Tinfold is not online. Tinfold
Joined: 11 May 2010
Total Posts: 1435
06 Sep 2014 02:42 PM
When I run the random code in command bar, it works fine.

When I run the script, the words are in the same order every time.

mirror

umbrella

stickman

etc EVERY time.

Help.



_G.CurrentBuild='book'
_G.guy=nil
_G.msg=nil
_G.gotit=false
builds={'book','apple','sun','lemon','watermelon','pineapple','ocean','boat','laptop','computer','xbox','pizza','eyeball','alien','dinosaur','roblox','lollipop','ice cream','popsicle','egg','tree','flower','tophat','CD','TV','candle','lemonade stand','knife','sword','pistol','clock','campfire','crossbow','arrow','quarter','couch','chair','lamp','chest','river','road','stop sign','gate','door','stickman','cup','iphone','beach','umbrella','cloud','storm','headphones','mirror','laser','flashlight','window','ninja','burger','sandwich'}
generateRandomBuild=function()
local bld=builds[math.random(1,#builds)]
print(bld)
return bld
end
_G.init=function(p,c)
ypcall(function()
_G.guy:LoadCharacter()
end)
_G.guy=p
_G.gotit=false
local mes=Instance.new('Message',workspace)
if c=='start' then
mes.Text=p.Name .. ' has been chosen!'
elseif c=='win' then
mes.Text=p.Name .. ' got it right! ' .. _G.CurrentBuild
end
p.Character:MoveTo(workspace.TP.Position)
wait(2)
mes:Destroy()
for _,v in pairs(game.ServerStorage.Tools:children()) do
v:clone().Parent=p.Backpack
end
_G.CurrentBuild=generateRandomBuild()
local wurd=game.ServerStorage.wurd:clone()
wurd.holder.Frame.TextLabel.Text='Your word is: ' .. _G.CurrentBuild
wurd.Parent=p.PlayerGui

for i=1,120 do
wait(1)
if _G.gotit==true then
workspace.Clear:ClearAllChildren()
break
end
end
if _G.gotit==false then
local mes=Instance.new("Message",workspace)
workspace.Clear:ClearAllChildren()
mes.Text='Nobody has guessed the answer! ' .. _G.CurrentBuild
_G.CurrentBuild='book'
wait(2)
mes:Destroy()
wait()
_G.init(game.Players:GetChildren()[math.random(1,#game.Players:GetChildren())],'start')
end
end

game.Players.PlayerAdded:connect(function(plr)
wait()
plr.Chatted:connect(function(chat)
if string.lower(chat)==string.lower(_G.CurrentBuild) then
_G.gotit=true
_G.init(plr,"win")
end
end)
local num=#game.Players:GetChildren()
if num==1 then
_G.msg=Instance.new("Message",workspace)
_G.msg.Text='2 or more players are needed to start a game!'
elseif num>1 and num<3 then
ypcall(function()
_G.msg:Destroy()
_G.msg=nil
end)
local person=game:service'Players':GetChildren()[math.random(1,2)]
_G.init(person,'start')
end
end)

Report Abuse
Tinfold is not online. Tinfold
Joined: 11 May 2010
Total Posts: 1435
06 Sep 2014 02:48 PM
Please help me...
Report Abuse
devKorniak is not online. devKorniak
Joined: 09 Aug 2013
Total Posts: 228
06 Sep 2014 02:49 PM
tl;dr
Report Abuse
Tinfold is not online. Tinfold
Joined: 11 May 2010
Total Posts: 1435
06 Sep 2014 02:51 PM
gtfo you dumb goat
Report Abuse
devKorniak is not online. devKorniak
Joined: 09 Aug 2013
Total Posts: 228
06 Sep 2014 02:52 PM
hey, if you keep being rude:

1. Nobody's gonna answer.
2. You're gonna start a flamewar.
Report Abuse
alaneasy is not online. alaneasy
Joined: 13 Aug 2012
Total Posts: 55
06 Sep 2014 02:53 PM
BUMP,

C'mon skids...
Report Abuse
veryveryveryhidden is not online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
06 Sep 2014 02:59 PM
LMAO. ugly code
Report Abuse
GuestOfChaos is not online. GuestOfChaos
Joined: 01 Sep 2013
Total Posts: 71
06 Sep 2014 03:03 PM
ohai tinfold
Report Abuse
Tinfold is not online. Tinfold
Joined: 11 May 2010
Total Posts: 1435
06 Sep 2014 03:08 PM
forum doesnt support indents
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