How to make a simple dice game

Hello everyone! Welcome to my first Roblox Studio tutorial. In this tutorial, you will learn how to make a simple dice game. A couple of notes before starting the tutorial. First, this game drops dice once in every server. If you want them to be dropped again, I could make another tutorial on how to do that, or you can just rejoin the server. This is a remastered version of AlvinBlox’s tutorial. Now, let’s begin!

First, you need to open any game you want. If you don’t have any games, just create a baseplate. Next, you have to have the Explorer and Properties tabs open.
image
Now, we will make the dice. Insert a part into the game, and name it “Dice1”
Go to the properties of the dice, and change the color to institutional white. Make the material smooth plastic, and make the size 15,15,15. Now anchor it. It should end up looking like this
image
Now we will add the numbers to the dice. Open up the toolbox, and click on images in the drop-down menu. Look up “Dice 1”. Insert it into the game, and drag it into the dice. You can change the side of the dice this number is on. Keep doing this with each number until you have the whole dice covered. Make sure each number is on a different side of the dice. Now your dice looks like this.
image
We’re almost done with the building! Click on the dice, and hold Ctrl + D to duplicate the dice. Now you have 2 dice. Name one of the dice “Dice2” Use the move and rotate tools to move your dice into the air and to change their positions. Make sure that “Dice1” is above “Dice2”
image
We have now finished with the building! Now insert a script into ServerScript Service and name it whatever you want. Open the script and type this:
game.Workspace.Gravity = math.random(150,200)
This line of the script finds the gravity of the game and makes it be a random number between 150 and 200. We have to change the gravity so that the result of the dice is different every time. Now, on the second line you type this:
print("Gravity is "..game.Workspace.Gravity)
This prints the gravity that is chosen by the game into the output, which is where you see if there are any errors in your script and where you can check if your script is working. Now, we have to make the dice fall. For this line you will write:
game.Workspace.Dice1.Anchored = false
Here, You unanchor the dice to make it fall. Now, you write:
wait(1)
This makes the script wait 1 second before the rest of the script is played. We want it to wait because the first dice should bounce off the second one for a better result. Now for the last line of the script you write:
game.Workspace.Dice2.Anchored = false
Here is what your finished script should look like:
image
Now, publish your game. If you don’t know how to do this, go to the top left of your screen and click “Publish to Roblox to…” and choose which game to publish it to. Set the settings of your game to be public, and you have yourself a dice game!

Thank you for reading this post and I hope this helped you. Leave any questions or comments down below.

13 Likes

You could also compare their normal vectors to the up vector of worldspace (0,1,0) and see which’s dot product was the closest to 1 then say that that face is the dice amount

Is this influenced by Alvinblox’s video by any chance? Even so, great and effective tutorial! Well done!

1 Like

Yeah! Like I said in the beginning of the post, this is a remastered version of his video.

2 Likes

Oh sorry about the redundant question. I asked this in 4 am in the morning so my brain must have blocked some parts of the tutorial.

1 Like