I want to randomize the starter character of each player that joins the game.
It works at first but when the player dies it changes their character.
I’m not really sure how I would fix this.
local StarterCharacter = game.StarterPlayer.StarterCharacter
local Teams = game:GetService("Teams")
local CharacterAssets = {
FaceDecals = {
"http://www.roblox.com/asset/?id=7075412";
"http://www.roblox.com/asset/?id=629933140";
"http://www.roblox.com/asset/?id=255828374";
"http://www.roblox.com/asset/?id=8560912";
"http://www.roblox.com/asset/?id=110287880 ";
"http://www.roblox.com/asset/?id=7131857";
"http://www.roblox.com/asset/?id=66329994";
"http://www.roblox.com/asset?id=478720454";
"http://www.roblox.com/asset/?id=405706600";
}
--
,Shirts = {
"http://www.roblox.com/asset/?id=5278505376";
"http://www.roblox.com/asset/?id=5230828058";
"http://www.roblox.com/asset/?id=5103634376";
"http://www.roblox.com/asset/?id=5103631170";
"http://www.roblox.com/asset/?id=5038072916";
"http://www.roblox.com/asset/?id=809740790";
"http://www.roblox.com/asset/?id=3229564100";
"http://www.roblox.com/asset/?id=2312441456";
"http://www.roblox.com/asset/?id=4713882231";
}
--
,Pants = {
"http://www.roblox.com/asset/?id=5242202148";
"http://www.roblox.com/asset/?id=5113695723";
"http://www.roblox.com/asset/?id=218279985";
"http://www.roblox.com/asset/?id=414289341";
"http://www.roblox.com/asset/?id=414289922";
"http://www.roblox.com/asset/?id=1307478812";
"http://www.roblox.com/asset/?id=358710109";
}
}
function Randomize(StarterCharacter)
StarterCharacter:WaitForChild("Head").face.Texture = CharacterAssets.FaceDecals[math.random(1, #CharacterAssets.FaceDecals)]
StarterCharacter:WaitForChild("Shirt").ShirtTemplate = CharacterAssets.Shirts[math.random(1, #CharacterAssets.Shirts)]
StarterCharacter:WaitForChild("Pants").PantsTemplate = CharacterAssets.Pants[math.random(1, #CharacterAssets.Pants)]
end
game.Players.PlayerAdded:Connect(function(player)
Randomize(StarterCharacter)
player.Team = Teams.Lobby
end)