script.Parent.MouseButton1Down:connect(function() local player = game.Players.LocalPlayer local WhoClicked = player.Name game.Players[WhoClicked].Team = 'Baby/Child' end)
i keep getting this error 19:47:06.415 - Players.DaHazza.PlayerGui.Team Selector.Start.Baby/Child.LocalScript:4: bad argument #3 to 'Team' (Object expected, got string)
Although legoch2's answer did work, there's an easier and more sufficient way to do this and it isn't completely altered from your original code.
1 | script.Parent.MouseButton 1 Down:connect( function () |
2 | game.Players.LocalPlayer.Team = game.Teams [ 'Baby/Child' ] |
3 | end ) |
Both you and lego's scripts used unnecessary variables, which were pretty much pointless, this just makes it into one quick efficient line.
Hey! Assuming it's a local script...
1 | local player = game.Players.LocalPlayer |
2 | local Team 2 = game.Teams.Test 2 -- Replace Test2 with your team name |
3 |
4 | script.Parent.MouseButton 1 Down:connect( function () |
5 | player.Team = Team 2 |
6 | end ) |
If you need anymore help leave a comment Otherwise Enjoy!