math.randomseed(tick()) local skinT = {"125", "1030", "18"} local player = game.Players.LocalPlayer repeat wait() until player.Character local character = player.Character local bColors = character:WaitForChild("Body Colors") local newskin = skinT[math.random(1,3)] bColors.HeadColor = BrickColor.new(newskin) bColors.LeftArmColor = BrickColor.new(newskin) bColors.RightArmColor = BrickColor.new(newskin) bColors.TorsoColor = BrickColor.new(newskin) bColors.LeftLegColor = BrickColor.new(newskin) bColors.RightLegColor = BrickColor.new(newskin) local shirt = character:WaitForChild(Shirt) shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=167295776" local pant = character:WaitForChild(Pants) pant.PantsTemplate = "http://www.roblox.com/asset/?id=112052973" local head = character:WaitForChild(Head1) head.BrickColor = BrickColor.new(newskin)
Same thing as before, but now the skin colors work. The problem now is that the shirt, pants, and the head won't change to what I want it to. When it does work, it doesn't work all the time.
The argument of WaitForChild
needs to be a string. Also, not everyone is going to have shirts and pants, so you need to deal with that.
In this case, the scripts makes a new shirt and pants. Then, in a new thread, the script waits for the old clothing to be added, then destroys it. A new thread is necessary so the script doesn't get stuck waiting for clothing to be added.
math.randomseed(tick()) local skinT = {"125", "1030", "18"} local player = game.Players.LocalPlayer repeat wait() until player.Character local character = player.Character local bColors = character:WaitForChild("Body Colors") local newskin = skinT[math.random(1,3)] bColors.HeadColor = BrickColor.new(newskin) bColors.LeftArmColor = BrickColor.new(newskin) bColors.RightArmColor = BrickColor.new(newskin) bColors.TorsoColor = BrickColor.new(newskin) bColors.LeftLegColor = BrickColor.new(newskin) bColors.RightLegColor = BrickColor.new(newskin) local shirt = Instance.new("Shirt",character) shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=167295776" shirt.Name = "NewShirt" coroutine.wrap(function() character:WaitForChild("Shirt"):Destroy() end)() local pant = Instance.new("Pants",character) pant.PantsTemplate = "http://www.roblox.com/asset/?id=112052973" pant.Name = "NewPants" coroutine.wrap(function() character:WaitForChild("Pants"):Destroy() end)() local head = character:WaitForChild("Head") head.BrickColor = BrickColor.new(newskin)