Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

person who clicked change team plz help?

Asked by 6 years ago

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

Log in to vote
3
Answered by 6 years ago

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.

0
Also remember that :connect() is deprecated, use :Connect() instead. But upvote otherwise. PyccknnXakep 1225 — 6y
0
:connect() isn't deprecated? I have never been told that by ANYONE. ObscureIllusion 352 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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!

0
THANK YOU SOOOO MUCH DaHazza 0 — 6y
0
ill keep you in contact in case i have any other scripting problemd DaHazza 0 — 6y
0
All goods just make sure to accept the answer if it is correct :) legoch12 45 — 6y

Answer this question