Random Chance in Game (Uses Blocks)

In my game which was supposed to simulate the odds of getting a Gimfish I had a bit of trouble so I had to do a bit of research to find out and decided to share it with the rest of the community.

When you create it you want to first wire a trigger to a button (you can change it slightly like swapping the button with a zone) and then you click the trigger and select ‘Blocks’. Next you want to select the ‘Variables’ tab and then create a variable by the name of ‘RandomNumber’ (or anything you want to represent a random number). After that you want to select ‘Set Random Number To’ block and a 'Random Integer [] to []' from the ‘Essential’ tab and set it to the chance you want (for example, if you wanted a 1% chance for something you would need to do 'Random Integer [1] to [100]' (using the number block from ‘Essentials’).

Now you want to select an 'If [] Do []' from the ‘Logic’ tab. Next attach a [] = [] block from ‘Logic’. Now going from the 1% chance I said earlier you want to put another block ('Random Number' from 'Variables') in the first blank of the [] = [] block, then in the second you want to put another number block and set it to 1.

For the final steps you want to get a ‘Broadcast on Channel’ from ‘Essentials’ and attach it to the ‘Do’ part of 'If [] Do []' and then get a "[]" from the ‘Text’ tab. and attach it to the right side of ‘Broadcast on Channel’ block. and in the at block ("[]") type your channel name, in this case I’m going to use ‘a’. If you want many random chances you just do this entire paragraph of steps as many times as you want, all you just have to do is click the ‘*’ button in the 'If [] Do []' block and select 'Else If' as many times as you want.

Now get an ‘Item Granter’, set your item, put your channel in the slot for granting titled ‘Grant Item When Receiving Channel’ an your done!


(Random chance for 2 items, ‘a’ is item 1, ‘b’ is item 2, edit to how you want it)

7 Likes
  1. Add some images in a few days once you have a high enough trust level
  2. Fixed the formatting, four spaces/tab key won’t work here
  3. Duplicate guide to some extent.
5 Likes

My eyes hurt from looking at paragraphs , please add images.
Wait why is this in devices shouldn’t it be in Community Made Guides
Thanks WSG for changing it I forgot I could change it myself.

1 Like

Yeah someone else did a guide like this already, also this should not be in devices

Yeah, images and drop downs help a lot. Having a messy paragraph isn’t the best. Also, and end result could be good. Demo raises a good question, why is this devices? Turtle did you not see it or is it supposed to be devices? I’ll change it to Community Made Guides for now until someone wiser looks at this.

2 Likes

After reading this through I think he means that using the random integer block and if = true then block to make random chance. I think, correct me if I’m wrong.

@GimfishGuy I’m super sorry for doing this without asking first, but I noticed that when Turtle edited your guide they made all of your brackets ([]) transform into checkboxes , so I went back and made them preformatted text so they looked how they originally were supposed to.

If you want it changed back, just @ me, but I hope you like it and feel free to drop a comment about how you feel about what I did (or privately message @moderators because you want my ability to edit all posts reprimanded) and I’ll see if there’s anything I can do.

5 Likes

its alright, I like the brackets better myself