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 4 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()

local plr = game.Players.LocalPlayer

if plr then

    if plr.TeamColor == allowedTeam then

        plr.TeamColor = changedTeam;

        plr:LoadCharacter();

    end

end

end)

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 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

local teamone = game.Teams.TEAMNAMEHERE
local teamtwo = game.Teams.TEAMNAMEHERE
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() --This may of been your issue. You had a lowercase b in button. But this is a better way
    if player.Team == teamone then
        --do something
    elseif player.Team == teamtwo then
        --do something
    end
end)
Ad

Answer this question