StarterCharacter scale's not changing

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)
1 Like

The script doesn’t work due to you changing the model’s scale incorrectly. There is actually a function that you can use to change model’s scale called ScaleTo()

I changed the last line of code in setRandomCharacter() function from model.Scale = 0.4 to model:ScaleTo(0.4).

Here is the changed script:

Code
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:ScaleTo(0.4)
end

Players.PlayerAdded:Connect(function(player)
	setRandomCharacter()
	player.CharacterAdded:Connect(function(char)
		applyColors(char)
		setRandomCharacter()
	end)
end)

:exclamation:IMPORTANT: The character’s speed and jump power change accordingly to character’s scale. If you want to keep the speed and jump power the same, make sure to include that in your script.

If there are still any issues, please let me know!

1 Like