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)

21 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.
11 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.

2 Likes

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

1 Like

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.

5 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.

2 Likes

@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.

9 Likes

its alright, I like the brackets better myself

2 Likes

Hi! It has been a long time since you posted this and i needed a randomizer for my game like Fishtopia, a random fish so i decided to try this out and it didn’t work… i followed what you said, i did the blocks, and i got the item granter, so what was wrong?
so there is a button at a lake that says Fish! and once you press it, the channel Trigger is broadcasted, and that leads to a trigger that triggers when channel says Trigger (sorry). here are the blocks in the trigger:

and there are item granters on top that grant different fish depending on what broadcasts, like fish1 or fish5 whatever. it said grant item when receiving on channel too…
then i tried it out and it didnt work. so did i do anything wrong?

Sorry if this is too long and hope you can help, thx:)!

3 Likes

Alright. So there are a few problems with this, let’s go through this.

1st: your variables are all different. all the redish purple blocks should all be “RandomFish”.



2nd: every single else if statement says =1. basically they’re all doing the same thing. So change it to 1-5 downwards



8 Likes

Also, the random integer is set from 1 to 100, but the blocks only check values up to 5.

8 Likes

Thank you so much! I will change that:)

2 Likes

So i should make it random integer 1-5, right? So that its just 5?

3 Likes

Yes! That’s definitely a good choice.

3 Likes

It worked! Thank you:D

3 Likes

bump
bro I was gonna make a similar guide and I didn’t know this existed :sob:
[1]




  1. ↩︎

5 Likes

Isn’t this more efficient block code?
Screenshot 2025-05-22 8.10.03 AM

3 Likes

are these blocks on a trigger?

1 Like

these blocks can be on any device that supports block code
ex.

trigger
text
game overlay
item granter
etc.

1 Like

Ok but what does each block combination thing do?

1 Like