I want to make a game like blood and iron but based in another time period, the problem is I'm a a noob when it comes to team changing and class changing scripts, especially the blood and iron class change options which looks difficult and confusing to script so I'm here to ask if anyone could help me out?
Some people haven't played that game, explaining more about it would be helpful.
https://developer.roblox.com/api-reference/event/GuiButton/MouseButton1Click
Using the MouseButton1Click
event, we can tell if a Player
has clicked on a GuiButton
. This will give us information on what team the player wants to join.
https://developer.roblox.com/api-reference/property/Player/Team
When a player is on a team, the PlayerObject
has a property: Player.Team
. We can use this to set or switch the player's team.
https://developer.roblox.com/api-reference/function/Team/GetPlayers
To check the amount of players on a team, we can use Team:GetPlayers()
to return a table containing all the players on that team. #Team:GetPlayers()
will give us the number of players on that team and with some comparing, we can make sure the teams are balanced.
https://developer.roblox.com/articles/Remote-Functions-and-Events
Since your game should be Filtering Enabled, we must use RemoteEvents to communicate between the Client and the Server. We have to do this because MouseButton1Click
is only used on the Client. Have the client RemoteEvent:FireServer()
to send a signal on what team they want to join and have the server listen for the signal with RemoteEvent.OnServerEvent
and set the player's Team
accordingly.