Case Opening System

My team need to know how to make a case system / opening system for a sword fight game to unlock different swords etc. We’ve looked through a lot of sources and cant find anything on the topic, any help would be appreciated,

2 Likes

Case system is something that is a little complicated at first but once you know what to do it’s as easy as er pie yes. I’ll tell you the method I used to make my own case opening system. I’m not sure if mine is efficient enough but I just go with whatever seems like the best for me.

First I created the case GUI with loot probability by using weight system the code I used is pretty similar to this topic right here (because math random is not the best choice in my opinion to be the main randomiser code). And since I need something to indicate that the loot has been selected I also added that tiny red line. (I’ll tell you what it does in the next- next step)

All of the loots will be automatically sort out by using UIListLayout then I ran the randomiser code 200 times just to spawn the appropriated amount of loot. (Of course you could go even higher than that but I think 200 is good enough) Here is what it should look like if I ran it 5 times.

Screen Shot 2564-01-24 at 08.39.04

  • The blue box is where the start is with UIListLayout going in right side.
  • The red box is the sorted out loot.
  • The green box is the main frame.
  • The yellow line is the indicator line that I talked about earlier.

But you may ask, how would that help me with the loot box system?. Well… those 5 loot box will be selected through the yellow line or indicator line. To begin the selection I make the blue box go to the left side for about -math.random(3000, 5000) * 2 or -6000 to -10000 gui studs?. And then I used GetChildren() function to get all of the loot box after I ran it. Checking for the box that is the closest to the indicator line. And then return the result. If you want the box to travel just like in the video then you would need to fire a remote with the distance information to the client and then use the TweenService to make it move to the left. (The reason I calculated the distance in the server is to not let any exploiter get the goodies through client)

sorry if this is pretty long and quite confusing to understand

5 Likes

Thank you for your time, I will try incorporate this function and hope it will work after some extra research :>

1 Like

Hey, I know this is an old post, but how exactly did you get the box closest to the indicator?

I get all of the boxes’ x axis absolute position and compared it to the line x axis absolute position, something along the line like this

local Magnitude = (Box.AbsolutePosition.X - Indicator.AbsolutePosition.X)

to find the cloest box, yea

Hey, sorry to bother again, but it still has some issues, like sometimes it might award the item next to said box


For example, here it will award the ice valk

and it’s only ever the item to the right

i know this is late, but maybe you forgot to set the AnchorPoint to the middle, so it picks the one on the right because its anchor point is closer to the indicator. hope i helped :smiley:

hey, what element would i set the anchorpoint to?

Did you ever find a solution to this? I’ve been having the exact same problem. Setting the anchors to the middle didn’t fix it either

1 Like

No, I ended up ditching the project lol

moving the indicators X axis worked for me

local Magnitude = (Box.AbsolutePosition.X - (Indicator.AbsolutePosition.X - (Box.AbsoluteSize.X/2)))

damn im late again, you should set the anchorpoint to {0.5,0.5} , thats what i think i ment by “set the anchorpoint to the middle”, sorry for the late response