I made a script that is activated by pressing a button, then it adds a team with the same name as the text in a text button, however, everything works except the name, when I hit the button, the team is added, turned blue, but doesnt have a name.
local teamservice = game:GetService("Teams") game.ReplicatedStorage.Events.TeamAddedEvent.OnServerEvent:Connect(function() local text = game.StarterGui.Editor.CreateTerritory.TextButton.TextBox local newteam = Instance.new("Team",teamservice) newteam.Name = text.Text newteam.TeamColor = BrickColor.new("Bright bluish green") end)
You've got the right idea but if anything you'd have to FireClient (as well as adding it to the StarterGui) to add it to the PlayerGui too.
-- Client local Button = script.Parent -- obviously relocate this to your button local Players = gameGetService('Players') local Player = Players.Player local replicatedStorage = game:GetService('ReplicatedStorage') local teamEvent = replicatedStorage.Events.TeamAddedEvent Button.MouseButton1Click:Connect(function() -- you can use this dicationary to add more info on the team later on if you want local teamInfo = { teamName = teamName.Text -- obviously relocate to your textbox } teamEvent:FireServer(teamInfo) end) teamEvent.OnClientEvent:Connect(function(Team) -- with this you can update the UI for all players, keep in mind you sent over the actual team so all properties about the class can be seen here too, color, name, etc local newTeamButton = Instance.new('TextButton') newTeamButton.Parent = Player.PlayerGui.UI -- change this to your ui parent obviously -- more properties here :) end)
Then from here, connect to the Server.
-- Server local teamService = game:GetService('TeamService') local replicatedStorage = game:GetService('ReplicatedStorage') local teamEvent = replicatedStorage.Events.TeamAddedEvent teamEvent.OnServerEvent:Connect(function(Player, teamInfo) local newTeam = Instance.new('Team') newTeam.Parent = teamService newTeam.Name = teamInfo.teamName -- you should add a check here for a random team color generator for a team color that isn't taken newTeam.TeamColor = BrickColor.new("Bright bluish green") teamEvent:FireAllClients(newTeam) -- fire back to all the clients end) -- OnServerEvent
use text:GetPropertyChangedSignal("Text")
instead of text.Text