|
| 04 Aug 2015 12:14 AM |
In studio it is truly random, but when it hits server side it ALWAYS hits 2 everytime the server starts up, its 2.
I have no idea.
Math = math.random(5)
while game.Players.NumPlayers >= 2 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end end |
|
|
| Report Abuse |
|
|
Funse
|
  |
| Joined: 11 Jun 2012 |
| Total Posts: 7887 |
|
| |
|
robomax11
|
  |
| Joined: 07 Jul 2011 |
| Total Posts: 6828 |
|
|
| 04 Aug 2015 12:21 AM |
puesdo random number generator
you can't be truly random.
just unpredictability
love me |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 12:37 AM |
Ok I got it to give me random numbers, but I can't put those numbers in variables
|
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 01:24 AM |
| To reword this. I have got it to truly be random, the problem is, now I can't play my music. |
|
|
| Report Abuse |
|
|
Sevrick
|
  |
| Joined: 22 Oct 2013 |
| Total Posts: 3846 |
|
| |
|
| |
|
Tuneable
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 2932 |
|
|
| 04 Aug 2015 01:58 AM |
math.randomseed(tick())
local Math = math.random(5)
while game.Players.NumPlayers >= 2 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end Math = math.random(5) end |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 02:11 AM |
| I keep getting a set number. I heard this changes with each server though. Is that true? |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 02:19 AM |
Ok so now it is "randomized" to hit 1 and 5 now.
It skips 2 3 4
math.random(tick()) Math = math.random(5)
while game.Players.NumPlayers >= 2 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end end |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 04 Aug 2015 02:51 AM |
r u srs, you forgot the wait()
local T = {FirstSong, SecondSong, ThirdSong, FourthSong, FithSong}
while game.Players.NumPlayers >= 2 do wait(15) T[math.random(1, #T)]:Play() end |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 04 Aug 2015 02:53 AM |
oh and don't use the ugly math.randomseed(tick())
math.random() is as random as it gets |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 02:54 AM |
IT is random lol.
You could do math.randomseed or wth it is
or you could
repeat thing1 = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren()] if thing.name = script.prev.Value then local thing1 = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren()] until thing.name ~= script.prev.Value
script.prev.Value = thing1.name
MIND the spelling errors
can't be fked to check over. |
|
|
| Report Abuse |
|
|
Tycooons
|
  |
| Joined: 13 Aug 2014 |
| Total Posts: 5871 |
|
|
| 04 Aug 2015 02:55 AM |
local Choice = { "FirstSong", "SecondSong", "ThirdSong", "FourthSong", "FifthSong" };
randNum = Math.random(5);
while game.Players.NumPlayers >= 2 do local Song = Choice[randNum] Song:Play() end |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 04 Aug 2015 02:58 AM |
| Look at all of these imbeciles forgetting the wait in there loops :V |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 03:28 AM |
THATS WHAT AUTO SAVES ARE FOR
I even sed i forgot sum things :P |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 03:31 AM |
local choices = 5 local randChoice = math.abs(math.random(1, choices) - tick()%choices) |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 03:33 AM |
random.seed or whtever the f it is is NOT RANDOM!
it doesn't RANDOMLY chooses any member of a list, therefore its not random. |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 03:33 AM |
Try this and this will show you what you are doing wrong
--------------------------------------------- Math = math.random(10)
for i = 1,10 do print(Math) end
wait(5)---------------------------------------------
for i = 1,10 do Math = math.random(10) print(Math) end
--------------------------------------------- |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 04 Aug 2015 03:34 AM |
Just use mine alredy :V
local T = {FirstSong, SecondSong, ThirdSong, FourthSong, FithSong}
while game.Players.NumPlayers >= 2 do wait(15) T[math.random(1, #T)]:Play() end |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 11:09 AM |
I'd never thought it would be this much trouble.
I got rid of math.randomseed(tick()) due to people saying its useless. This is my new code However note that this crashes my game, after when everything is completed and its trying to recall "Math" to play the song.
Math = math.random(5)
for i = 1,5 do print(Math) end
wait(5)
for i = 1,10 do Math = math.random(5) wait(1) print(Math) end
print(Math)
while game.Players.NumPlayers >= 1 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end end |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 11:24 AM |
| Also a fun little note, if I put another Math = math.random(5) in the while statement it plays all the songs :P |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 01:13 PM |
| It keeps crashing.... halp |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 01:23 PM |
alright I switched back to this
math.randomseed(tick()) Math = math.random(5)
while game.Players.NumPlayers >= 2 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end end
IT IS DISPLAYING THE NUMBER BUT ITS NOT PLAYING THE MUSIC even when i set the numplayers to >= 1 |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 08:56 PM |
Math = math.abs(math.random(1, 5) - tick()%5)
while game.Players.NumPlayers >= 2 do if Math == 1 then FirstSong:Play() elseif Math == 2 then SecondSong:Play() elseif Math == 3 then ThirdSong:Play() elseif Math == 4 then FourthSong:Play() elseif Math == 5 then FifthSong:Play() end end |
|
|
| Report Abuse |
|
|