I want to code how many stars someone has collected but it needs to follow some guidelines It's like Mario 64 or Roblox's Robot 64 if you've played it
1 | Stars need to be able to be collected in any order |
2 |
3 | Stars can be collected multiple times but only update the counter once |
4 |
5 | Stars are updated for only a single person, other people don't get the star |
I originally tried making an Array that held true or false values that would turn true when the star is collected, but this made it so only a single person in the server could collect that one star
You could make a table that holds the stars collected for each person. So when it it collected, you set another array inside the original array with the key as the players player object
, username
, userid
or anything that can relate back to the player.
For example:
01 | local stars = { } |
02 |
03 | onCollect:Connect( function () |
04 | local player -- However your going to get your player object |
05 |
06 | stars [ player ] = { } -- Using the player object as an example and creating an empty array. |
07 |
08 | if not stars [ player ] [ star ] then -- I don't know how you are going to get your star object |
09 | table.insert(stars [ player ] , star) -- Inserting the star into the players array |
10 | end |
11 | end ) |
Accept if this helped, as that would help me.