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

Help with this uniform script?

Asked by 8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

My goal is so that when the player respawns they are uniformed. Unfortunately, that isn't working..

local home;
local away;
function GetHome() -- To find the hometeam
    for i, v in pairs(game.Teams:GetChildren()) do
        if v:findFirstChild("home") then
            return v
        end
    end
    return nil
end

function GetAway() -- To find the away team
    for i, v in pairs(game.Teams:GetChildren()) do
        if v:findFirstChild("away") then
            return v
        end
    end
    return nil
end

home = GetHome(); --Set the variables
away = GetAway();

game.Players.PlayerAdded:connect(function(player) 
    player.CharacterAdded:connect(function(character)
        local a = player.TeamColor --Set the players teamcolor
        if a == home.TeamColor then --[[Find the team that corresponds to the teamcolor]]
            character.Shirt:remove() --Remove the shirt
            character.Pants:remove() --Remove the pants
            local shirt = home.Home.Shirt:Clone() --Set the shirt to be added
            local pants = home.Home.Pants:Clone() -Set the pants to be added
            shirt.Parent = character --Add the shirt
            pants.Parent = character --Add the pants
        elseif a == away.TeamColor then
            character.Shirt:remove()
            character.Pants:remove()
            local shirt = away.Away.Shirt:Clone()
            local pants = away.Away.Pants:Clone()
            shirt.Parent = character
            pants.Parent = character
        end


    end)
end)
0
What's the problem? BlueTaslem 18071 — 8y
0
When the character respawns the uniform isnt put on them. Ethan_Waike 156 — 8y
0
Is there any error? What debugging have you done? Do you realize the script you've pasted here has a syntax error on line 31? BlueTaslem 18071 — 8y
0
Yeah lol I added the comments Ethan_Waike 156 — 8y

1 answer

Log in to vote
1
Answered by
3dsonicdx 163
8 years ago

Just a notice - Instead of directly removing the shirt/pants - check whether they have those or not. It will error if they don't have either of those.

Or assuming they have shirts/pants - you can change the ID to the away/home ID instead of adding/removing.

Ad

Answer this question