I’m trying to add random heights in the game and I wanted to start out by just changing the Scale of the player to be smaller, as a test. I don’t know why but it doesn’t work. Any ideas?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local Players = game:GetService("Players")
local characterFolder = ReplicatedStorage:WaitForChild("Assets"):WaitForChild("Character")
local skinTones = {
Color3.fromRGB(255, 224, 189),
Color3.fromRGB(255, 219, 172),
Color3.fromRGB(241, 194, 125),
Color3.fromRGB(224, 172, 105),
Color3.fromRGB(198, 134, 66),
Color3.fromRGB(141, 85, 36),
Color3.fromRGB(120, 73, 30),
Color3.fromRGB(100, 60, 25),
Color3.fromRGB(80, 50, 20),
Color3.fromRGB(60, 40, 15)
}
local shirtColors = {
Color3.fromRGB(133, 76, 88),
Color3.fromRGB(100, 149, 135),
Color3.fromRGB(108, 117, 125),
Color3.fromRGB(100, 100, 200),
Color3.fromRGB(120, 80, 100),
Color3.fromRGB(80, 120, 90)
}
local pantColors = {
Color3.fromRGB(101, 67, 33),
Color3.fromRGB(72, 60, 50),
Color3.fromRGB(27, 42, 53),
Color3.fromRGB(99, 95, 98),
Color3.fromRGB(117, 112, 105),
Color3.fromRGB(150, 75, 0)
}
local targetParts = {
["Head"] = true,
["Torso"] = true,
["HumanoidRootPart"] = true,
["Left Arm"] = true,
["Right Arm"] = true,
["Left Leg"] = true,
["Right Leg"] = true
}
local function applyColors(char)
local skinColor = skinTones[math.random(1, #skinTones)]
local shirtColor = shirtColors[math.random(1, #shirtColors)]
local pantColor = pantColors[math.random(1, #pantColors)]
for _, part in pairs(char:GetDescendants()) do
if part:IsA("BasePart") then
if part.Name == "Torso" then
part.Color = shirtColor
elseif part.Name == "Left Leg" or part.Name == "Right Leg" then
part.Color = pantColor
elseif targetParts[part.Name] then
part.Color = skinColor
end
end
end
end
local function setRandomCharacter()
if StarterPlayer:FindFirstChild("StarterCharacter") then
StarterPlayer.StarterCharacter:Destroy()
task.wait(0.05)
end
local choice = math.random(1, 2) == 1 and "Male" or "Female"
local model = characterFolder:FindFirstChild(choice):Clone()
model.Name = "StarterCharacter"
model.Parent = StarterPlayer
model.Scale = 0.4
end
Players.PlayerAdded:Connect(function(player)
setRandomCharacter()
player.CharacterAdded:Connect(function(char)
applyColors(char)
setRandomCharacter()
end)
end)