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

I can't figure out the error with my team change script?

Asked by 5 years ago

I am trying to make it so when a player clicks a button (It's a ScreenGui) their team will be changed and their player will be loaded. Here's my script I can't figure out what i'm doing wrong. Btw this is a local script

--TEAM CHANGE--

local allowedTeam = BrickColor.new("White"); -- the color of the team they have to be on for it to change their team color--

local changedTeam = BrickColor.new("Really red"); -- the color i want them to change to when they click the button--

script.Parent.Mousebutton1Click:Connect(function()

01local plr = game.Players.LocalPlayer
02 
03if plr then
04 
05    if plr.TeamColor == allowedTeam then
06 
07        plr.TeamColor = changedTeam;
08 
09        plr:LoadCharacter();
10 
11    end
12 
13end

end)

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
5 years ago

Next time. Please make sure all of your code is in a codebox please. Thanks! Make this a serverscript or it wont change teams

01local teamone = game.Teams.TEAMNAMEHERE
02local teamtwo = game.Teams.TEAMNAMEHERE
03local player = game.Players.LocalPlayer
04 
05script.Parent.MouseButton1Click:Connect(function() --This may of been your issue. You had a lowercase b in button. But this is a better way
06    if player.Team == teamone then
07        --do something
08    elseif player.Team == teamtwo then
09        --do something
10    end
11end)
Ad

Answer this question