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

How do I make a script so that when a player joins he has specific clothing for the team he is in?

What I mean is that so if a player is on a criminal team he wears a criminal clothing and if a player is on the cop team he is wearing cop clothing.


local ChrNum = {"39563808","80254","1","48705637","15861410","42943434"}

local Randomizer = ChrNum[math.random(1,#ChrNum)]

game.Players.PlayerAdded:connect(function(plr)

    local use = true

    plr.CharacterAdded:connect(function(chr)

        if use == true then

            use = false

            plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..Randomizer.."&placeId="..game.PlaceId

            wait()

            plr:LoadCharacter()

        end

    end)

end)

1 comment

0

That isnt my code I just found it but I want to know how to edit it to my liking

1 answer

Your code does not have anything to do with teams. It also seems to only give the player one uniform every time, and is very inefficiently loading the uniform.

local charAppearances = {
[BrickColor.new("Really red")] = 0000, -- did you know you could use brick colors and objects as table indexes?
[BrickColor.new("Really blue")] = 0000 -- ID of appearance
}

function setAppearance(plr,bool)
	if bool == true then -- checks to see if the 'use' variable was true
		plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=" ..charAppearances[plr.TeamColor] or "".."&placeId=" ..game.PlaceId -- using the player's team color to choose appearance
	end
end

game.Players.PlayerAdded:connect(function(p)
	local use = true
	setAppearance(p,use) -- fires the function
	p.CharacterAdded:connect(function(char)
		setAppearance(p,use)
	end)
end)

If you have any more questions, please ask them!


Hope I helped!

~TDP

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