I tried to make a script by making a team with a custom name by typing the name and pressing a button on a GUI with FE, as I am learning about RemoteEvents, but when I tried assigning a team to the player I got this error:
13:32:43.078 - ServerScriptService.MakeTeam:7: bad argument #2 to '?' (string expected, got Object)
Here are the scripts
Local Script on the Button:
local button = script.Parent
local box = script.Parent.Parent.TeamName
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Events.MakeTeam:FireServer(box.Text)
end)
Script on ServerScriptService
game.ReplicatedStorage.Events.MakeTeam.OnServerEvent:Connect(function(player, teamName)
local team = Instance.new("Team")
team.Parent = game:GetService("Teams")
team.Name = teamName
team.TeamColor = BrickColor.Random()
game:GetService("Players")[player].Neutral = false
game:GetService("Players")[player].Team = team.Name
end)

2 comments
What is box? Is it a TextLabel?
Box is most likely a TextBox.