|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 02 Jan 2009 |
| Total Posts: 5557 |
|
| |
|
|
| 27 Sep 2017 01:51 PM |
"Ever heard of a typo?" A typo = death in scripting! |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|