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.
Example “Join”
“Joined”
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.
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.
--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)
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”.
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.
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.
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.
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.