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: Math.Random help!

Previous Thread :: Next Thread 
Glory2Asaissan is online. Glory2Asaissan
Joined: 11 Aug 2016
Total Posts: 55
27 Sep 2017 12:57 PM
i made a script and whenever a player joins the script make more then 1 dtat values then single.i want this script to make only 1 value not more then that.Can anyone help me?

game.Players.PlayerAdded:connect(function(Player)
wait(1)
chance = math.random(1,9)
if chance == 1 then
Quirk = Instance.new("StringValue",Player)
Quirk.Name = 'Data'
QuirkName = Instance.new("StringValue",Quirk)
QuirkName.Name = 'Quirk'
QuirkName.Value = 'OneForAll 100%'
end
if chance == 2 or 3 or 4 or 5 then
Quirk2 = Instance.new("StringValue",Player)
Quirk2.Name = 'Data'
Quirk2Name = Instance.new("StringValue",Quirk2)
Quirk2Name.Name = 'Quirk'
Quirk2Name.Value = 'OneForAll 1st Generation'
end
if chance == 5 or 6 or 7 then
Quirk21 = Instance.new("StringValue",Player)
Quirk21.Name = 'Data'
Quirk21Name = Instance.new("StringValue",Quirk21)
Quirk21Name.Name = 'Quirk'
Quirk21Name.Value = 'OneForAll 2nd Generation'
if chance == 8 or 9 then
Quirk212 = Instance.new("StringValue",Player)
Quirk212.Name = 'Data'
Quirk212Name = Instance.new("StringValue",Quirk21)
Quirk212Name.Name = 'Quirk'
Quirk212Name.Value = 'OneForAll 3rd Generation'
end
end
end)
Report Abuse
Extuls is online. Extuls
Joined: 02 Jan 2009
Total Posts: 5557
27 Sep 2017 01:06 PM
You have 5 twice. Also, you're using 'or' wrong. You have two options on how you could do it.

One way would be, for example;
if chance == 2 or chance == 3 or chance == 4 then

Or you could do it as;
if change == (2 or 3 or 4) then Either would work.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Sep 2017 01:18 PM
'if change == (2 or 3 or 4) then Either would work.'
No, that won't work.
You just wrote
if change == 2 then


Report Abuse
Extuls is online. Extuls
Joined: 02 Jan 2009
Total Posts: 5557
27 Sep 2017 01:49 PM
Ever heard of a typo?
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
27 Sep 2017 01:51 PM
"Ever heard of a typo?"
A typo = death in scripting!
Report Abuse
Extuls is online. Extuls
Joined: 02 Jan 2009
Total Posts: 5557
27 Sep 2017 02:02 PM
Still a typo. I'm sure the op would have caught it, seeing as it would have warned them if they literally just copied and pasted.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2017 02:18 PM
That's not a typo, that's just you doing it wrong.
Report Abuse
Extuls is online. Extuls
Joined: 02 Jan 2009
Total Posts: 5557
27 Sep 2017 02:21 PM
How is my solution wrong, besides the typo "change" instead of "chance"?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2017 02:22 PM
Talking about the method you go about doing it, not the fact you spelled chance wrong.
'if change == (2 or 3 or 4) then' is the same thing as doing 'if change == 2' as Jarod said
Report Abuse
Extuls is online. Extuls
Joined: 02 Jan 2009
Total Posts: 5557
27 Sep 2017 02:25 PM
Oh. Sorry.

I remembered doing something that way when I was first starting and tested using the first number. Assumed without doing a proper test.
Report Abuse
Glory2Asaissan is online. Glory2Asaissan
Joined: 11 Aug 2016
Total Posts: 55
27 Sep 2017 11:58 PM
ok i tried that but when i join the game in studio it just gives me data and does not show quirk in data.

game.Players.PlayerAdded:connect(function(Player)
wait(1)
chance = math.random(1,10)
if chance == 1 then
Quirk = Instance.new("StringValue",Player)
Quirk.Name = 'Data'
QuirkName = Instance.new("StringValue",Quirk)
QuirkName.Name = 'Quirk'
QuirkName.Value = 'OneForAll 100%'
end
if chance == 2 or chance == 3 or chance == 4 or chance == 5 then
Quirk2 = Instance.new("StringValue",Player)
Quirk2.Name = 'Data'
Quirk2Name = Instance.new("StringValue",Quirk2)
Quirk2Name.Name = 'Quirk'
Quirk2Name.Value = 'OneForAll 1st Generation'
end
if chance == 6 or chance == 7 or chance == 8 then
Quirk21 = Instance.new("StringValue",Player)
Quirk21.Name = 'Data'
Quirk21Name = Instance.new("StringValue",Quirk21)
Quirk21Name.Name = 'Quirk'
Quirk21Name.Value = 'OneForAll 2nd Generation'
end
if chance == 9 or chance == 10 then
Quirk212 = Instance.new("StringValue",Player)
Quirk212.Name = 'Data'
Quirk212Name = Instance.new("StringValue",Quirk21)
Quirk212Name.Name = 'Quirk'
Quirk212Name.Value = 'OneForAll 3rd Generation'
end
end)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
28 Sep 2017 12:17 AM
game.Players.PlayerAdded:connect(function(player)
wait(1)
local chance = math.random(1,10)
local quirk = Instance.new('StringValue',player)
local quirk2 = Instance.new('StringValue',quirk)
quirk.Name = 'Data'
quik2.Name = quirk.Name

if chance == 1 then
quirk2.Value = 'OneForAll 100%'
elseif chance == 2 or chance == 3 or chance == 4 or chance == 5 then
quirk2.Value = 'OneForAll 1st Generation'
elseif chance == 6 or chance == 7 or chance == 8 then
quirk2.Value = 'OneForAll 2nd Generation'
elseif chance == 9 or chance == 10 then
quirk2.Value = 'OneForAll 3rd Generation'
end
end)


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
28 Sep 2017 12:20 AM
oops made some typos

game.Players.PlayerAdded:connect(function(player)
wait(1)
local chance = math.random(1,10)
local quirk = Instance.new('StringValue',player)
local quirk2 = Instance.new('StringValue',quirk)
quirk.Name = 'Data'
quirk2.Name = quirk.Name

if chance == 1 then
quirk2.Value = 'OneForAll 100%'
elseif chance == 2 or chance == 3 or chance == 4 or chance == 5 then
quirk2.Value = 'OneForAll 1st Generation'
elseif chance == 6 or chance == 7 or chance == 8 then
quirk2.Value = 'OneForAll 2nd Generation'
elseif chance == 9 or chance == 10 then
quirk2.Value = 'OneForAll 3rd Generation'
end
end)


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