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.
script.Parent.MouseButton1Down:connect(function() game.Players.LocalPlayer.Team = game.Teams['Baby/Child'] 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...
local player = game.Players.LocalPlayer local Team2 = game.Teams.Test2 -- Replace Test2 with your team name script.Parent.MouseButton1Down:connect(function() player.Team = Team2 end)
If you need anymore help leave a comment Otherwise Enjoy!