I need a script that creates teams (or uses already existing ones, makes a ranking system for the teams, makes a overhead gui for it and lets users collect exp by interacting with a button of some kind.
Im mainly looking for help as to how this would be structured ideally and the best way to code it. I mainly ran into issues of teams not properly assigning ranks but i didn’t have a folder in game to handle this, it was all inside a server script.
So first off, you’d need a datastore (unless you want ranks/exp to reset on leave)
Alright, so then you should just make a few teams in studio. Not really that important what they are.
Im assuming you pick a team via gui. So you would need to just make a few textbuttons to pick the right team.
If its not via a gui, then you could make touching a part pick your team otherwise. Nothing too crazy though.
So we have a team selector, and you can change your team easily too.
The datastore is very important now.
In the player’s data structure, you should create (x) amount of folders, one for each team. This way, you can store data that is independent of other teams. X representing # of teams
This could be done by modifying a leaderstats type script to create 3 folders, then parent the relevant data values to each teams folder.
If you don’t want the leaderboard, just set the parents to replicatedstorage or serverstorage in a folder named the players UserId.
Okay, so each team has independent data and we can pick which one we want.
To retrieve a teams data, just use :GetAsync(p.UserId) like you normally would to retrieve data, then request DataFolder:FindFirstChild(“TEAM”). Where datafolder is just the folder containing all team folders for each player.
Great! Everything is essentially functional now.
So we retrieve PlayerA’s team A data. They have 1000 XP total, and lets say you get a level every 100 XP.
We can use simple math. XPCount / 100 = your Rank. Could you also save rank independent of XP if you want.
Okay, either way, we either retrieved the rank via data OR we used the simple formula above. Lets say they are rank 10. We can then match rank 10 to what rank we want it to be.
For example, you could make a module with index [#rank] = "rank name"