Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

person who clicked change team plz help?

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)

2 answers

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.

2 comments

0

Also remember that :connect() is deprecated, use :Connect() instead. But upvote otherwise.

0

:connect() isn't deprecated? I have never been told that by ANYONE.

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!

3 comments

0

THANK YOU SOOOO MUCH

0

ill keep you in contact in case i have any other scripting problemd

0

All goods just make sure to accept the answer if it is correct :)

This discussion is preserved as it was. New answers, comments, and votes are closed.