How to make an unboxing system/animation

Hello!

I have been searching for some videos regarding the subject but i haven’t found anything that fits what i’m looking for very well.

I need to make an unboxing system in my game for both unlockable characters and also skins, the unboxing is gonna be done by a random character/skin in different crates.

image

It is divided in two parts:

  1. Selecting a random character/skin that is obtainable in that box. Different character/skins have different rarities so the rarer ones should have a smaller chance.

  2. A simple animation of the box opening.

If anyone could recommend me videos or tell me how i can do those two steps, it would help a ton.

Thanks!

To answer your first requirement, you can store a library of your accessible characters, their rarity & their price. When the player clicks on a prompt, utilise InvokeServer on a RemoteFunction, the only information you should be sending from the client is the player (which is predefined in the function), and a designated ID of the crate at hand, i.e:

Wooden Crate: 1,
etc..

Or, just send the crate name to the server.

From here you can use your DataStore method to get their currency, and verify if they have the accessibility to purchase this crate, if they cannot do something return false from your RemoteFunction to tell the client that the opening system has failed, or you can send the exact reason in the return parameter.

From here you can do all your other necessary things, checking the price, subtracting the price and firing the opening event/function.

You should never store your prices or the checking/subduction of price on the client.

What method of opening do you exactly want, are you trying to animate the box?

2 Likes

For the opening it’s not a big deal, anything works.

Two ways i though about it was either just have the box fall on the screen and have a very simple animation or just the default spin wheel like in jailbreak and all.

There’s certainly a lot of options, if you are not familiar with maybe ViewportFrames, or you find it difficult managing animations or physically creating and displaying the character or skin then the best bet for you is an animated UI function of sort.

This is an exceptionally easy method of displaying rewarded information, you could possibly:
Once you’ve successfully verified they can afford the product, and have subducted the crates price, (and of course, got the rarity, you can use a basic math.random() function if you want an easy workaround), you can return your RemoteFunction with a unique success parameter, I’d suggest just return true works fine, as we are handling all our important features on the server, this does not need anything special.

You can detect this invoke by the following method:

local CrateFunction = --RemoteFunction instance here

local CrateInvoke = CrateFunction:InvokeServer(CRATE)
if CrateInvoke.hasSucceeded then --.hasSucceeded is NOT built in, we returned it in a table prior
-- we could handle this better but for efficiency purposes we'll presume nothing went wrong
end

From here, I presume you understand making basic UI animations, if not I can send a few tutorials, otherwise, we can format our animation as the following:

if CrateInvoke.hasSucceeded then
   local UnlockedCharacterName = CrateInvoke.CharacterName --NOT BUILT IN, we returned it
   local UnlockedCharacterRarity = CrateInvoke.CharacterRarity --NOT BUILT IN, we returned it

   doUIAnimation(UnlockedCharacterName, UnlockedCharacterRarity)
end

If you do not understand RemoteFunctions, or some of my wording does not make sense, I can send you over a quick game-file which will have all the code.

1 Like

You can also animate any objects that has a humanoid. Although humanoids are quite costly. So you could create a rig too.

Yeah, I don’t know how this part works, the rest is fine though.

Some other things i didnt quite get:

  • In which way exactly would i store the library? Just using instances maybe in ReplicatedStorage?

  • How can i randomize the card the player will get? You said to “store a library of your accessible characters, their rarity & their price” but you didn’t specify how exactly i would randomize the card.

1 Like

ExampleCrateWorkspace.rbxl (46.5 KB)

I’ve compiled the basic functions into a readable code file, take a look around.

1 Like