Team Selector Gui Change

  1. What do you want to achieve? So for example if a player is in team1 and they hover over the team 1 gui selector a gui where the Join button usually is says “Selected” and when they hover over the team2 join gui it says “Select”. And if they player was in team2 and they hovered over the team1 gui it would say “Select” Instead of “Selected” And if they hovered over the team2 gui it would say “Selected”.

Basically i want to know what the best way to do this is and how to do it as i have no clue on where to begin. I was thinking maybe having a script detecting what team the user is in and based off that it will display the gui it needs but i have searched and i couldn’t find anything.

  1. Example “Join”
    image

“Joined”

image

  1. What solutions have you tried so far? I have had a search through some youtube tutorials but have found nothing so far. And I can’t find anything related to what i want doing on the dev forum.

All i ask is for someone to tell me a way to do it and possibly link me with some articles that can help. I’m doing this to get better and learn how to become a better scripter.

Thanks.

3 Likes

Haven’t touched scripting in a while since I am primarily doing UI design work right now but I’ll tell you what to do.

Although there may be a more efficient solution to fixing this, I would add values to check if whether or not that player has joined that team. It would be changed whenever a team change occurs. The buttons will change according to what value they are monitoring to.

1 Like
--Local script
local RS = game:GetService("ReplicatedStorage")
local remote = RS:WaitForChild("ChangeTeam")

for _,button in pairs(script.Parent:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()
			remote:FireServer(button.Name)
			button.Text = "Selected"
		end)
		button.MouseEnter:Connect(function()
			button.Text = "Select"
		end)
		button.MouseLeave:Connect(function()
			button.Text = button.Name
		end)
		
	end
end

--Server script
game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(function(Player,Team)
   if Player then
     local RealTeam = game:GetService("Teams"):FindFirstChild(Team)
	 if RealTeam then
		Player.Team = RealTeam
   	 end
   end
end)

image

1 Like

Result:

robloxapp-20220421-1410224.wmv (458.5 KB)

Model:
https://www.roblox.com/library/9426929818/Simple-team-selector

1 Like

Thanks, i will give this a go right away.

1 Like

Hey, so it does partially what i want. However i also want to include when i rehover my mouse over the team i just selected it continues to say “Selected”.

No problems, I’ll update it now and send it to you

1 Like

Thank you so much for your help. :slight_smile:

1 Like

Here, updated the model :

https://www.roblox.com/library/9426929818/Simple-team-selector

1 Like

Thanks so much. Really appreciate the help :slight_smile:

1 Like

Hello, i recently implemented this into my main menu and well we are having some issues.

In the video it shows the button being renamed to what the button is called. Is there a way i can remove it and instead have it so it says Joined or Join if i didn’t click the button instead of the button being reverted back to the button name.

image

Yes, you can remove the button simply after the player has pressed on it, if you want to update the server with that, fire a remote and close the UI on the server, if not - simply use :Destroy() to destory that button.

1 Like

No, i don’t want to remove the button. I just want the button to change to the text either “Join” if i havent yet joined or “Joined” if i clicked join. I don’t want the button text being renamed to the button name when i click on it and move my mouse away.

Because at the moment the button changes to the text ClassD (the name of the button).

Oh, then remove this part -

button.MouseLeave:Connect(function()
	button.Text = button.Name
end)
1 Like

Starting to work but now even though im not on that team it says Joined. Anyway to make it go back to Join if i join another team?

Do you mind sharing the file? [so that I’d be able to see it and edit it and give you it back with notes]

This would help me editing it with your UI’s, so that you won’t need to change the UI or anything.

It’s a bad idea to just straight up and give them a working model/script without explaining what it does. You should instead teach them how to do it step by step.

1 Like

Alright, gonna take a look into it now.

1 Like