Scaling Command Help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I came up with the idea of making a scaling command and I was messing around with the player scales and found this method then I tried to make this script and it works fine but there are some things I want to add and need help with and if it’s too much to ask for I’m sorry I just really wanted to finish this but it’s way out of my knowledge. If I’m doing it completely wrong just tell me and I’ll try to look for a new way to make it.

  1. What is the issue? Include screenshots / videos if possible!

I wanted to make this script more efficient so that I don’t need soo many command locals and I also want to set a limit to what scale players can scale up and down too. I want it to go 0.5 of the player’s original scale and up to 2x the player scale because there is no limit set right now and I don’t know how to make that is too advanced for my understanding.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Well, I have tried to make a limit to scaling by making it 0.5 - 2 but if you keep doing !scale 2 over and over again you get pretty big, same with the other commands. But I have searched on the Devforum and I haven’t found anything that can really help me.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


local Command1 = "!scale 0.5"
local Command2 = "!scale 0.6"
local Command3 = "!scale 0.7"
local Command4 = "!scale 0.8"
local Command5 = "!scale 0.9"
local Command6 = "!scale 1"
local Command7 = "!scale 1.1"
local Command8 = "!scale 1.2"
local Command9 = "!scale 1.3"
local Command10 = "!scale 1.4"
local Command11 = "!scale 1.5"
local Command12 = "!scale 1.6"
local Command13 = "!scale 1.7"
local Command14 = "!scale 1.8"
local Command15 = "!scale 1.9"
local Command16 = "!scale 2"


--[[

These are the values you have to change to change the players scale
BodyDepthScale
BodyHeightScale
BodyProportionScale
BodyTypeScale
BodyWidthScale
HeadScale

]]--

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(chr)
		player.Chatted:Connect(function(msg)

			local BDS = player.Character.Humanoid.BodyDepthScale.Value
			local BHS = player.Character.Humanoid.BodyHeightScale.Value
			local BPS = player.Character.Humanoid.BodyProportionScale.Value
			local BTS = player.Character.Humanoid.BodyTypeScale.Value
			local BWS = player.Character.Humanoid.BodyWidthScale.Value
			local HS = player.Character.Humanoid.HeadScale.Value



			if msg == Command1 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*0.5
					player.Character.Humanoid.BodyHeightScale.Value = BHS*0.5
					player.Character.Humanoid.BodyProportionScale.Value = BPS*0.5
					player.Character.Humanoid.BodyTypeScale.Value = BTS*0.5
					player.Character.Humanoid.BodyWidthScale.Value = BWS*0.5
					player.Character.Humanoid.HeadScale.Value = HS*0.5
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command2 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*0.6
					player.Character.Humanoid.BodyHeightScale.Value = BHS*0.6
					player.Character.Humanoid.BodyProportionScale.Value = BPS*0.6
					player.Character.Humanoid.BodyTypeScale.Value = BTS*0.6
					player.Character.Humanoid.BodyWidthScale.Value = BWS*0.6
					player.Character.Humanoid.HeadScale.Value = HS*0.6
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command3 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*0.7
					player.Character.Humanoid.BodyHeightScale.Value = BHS*0.7
					player.Character.Humanoid.BodyProportionScale.Value = BPS*0.7
					player.Character.Humanoid.BodyTypeScale.Value = BTS*0.7
					player.Character.Humanoid.BodyWidthScale.Value = BWS*0.7
					player.Character.Humanoid.HeadScale.Value = HS*0.7
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command4 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*0.8
					player.Character.Humanoid.BodyHeightScale.Value = BHS*0.8
					player.Character.Humanoid.BodyProportionScale.Value = BPS*0.8
					player.Character.Humanoid.BodyTypeScale.Value = BTS*0.8
					player.Character.Humanoid.BodyWidthScale.Value = BWS*0.8
					player.Character.Humanoid.HeadScale.Value = HS*0.8
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command5 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*0.9
					player.Character.Humanoid.BodyHeightScale.Value = BHS*0.9
					player.Character.Humanoid.BodyProportionScale.Value = BPS*0.9
					player.Character.Humanoid.BodyTypeScale.Value = BTS*0.9
					player.Character.Humanoid.BodyWidthScale.Value = BWS*0.9
					player.Character.Humanoid.HeadScale.Value = HS*0.9
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command6 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1
					player.Character.Humanoid.HeadScale.Value = HS*1
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command7 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.2
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.1
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.1
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.1
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.1
					player.Character.Humanoid.HeadScale.Value = HS*1.2
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command8 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.2
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.2
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.2
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.2
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.2
					player.Character.Humanoid.HeadScale.Value = HS*1.3
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command9 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.3
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.3
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.3
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.3
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.3
					player.Character.Humanoid.HeadScale.Value = HS*1.4
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command10 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.4
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.4
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.4
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.4
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.4
					player.Character.Humanoid.HeadScale.Value = HS*1.5
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command11 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.5
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.5
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.5
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.5
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.5
					player.Character.Humanoid.HeadScale.Value = HS*1.6
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command12 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.6
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.6
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.6
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.6
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.6
					player.Character.Humanoid.HeadScale.Value = HS*1.7
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command13 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.7
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.7
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.7
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.7
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.7
					player.Character.Humanoid.HeadScale.Value = HS*1.8
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command14 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.8
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.8
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.8
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.8
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.8
					player.Character.Humanoid.HeadScale.Value = HS*1.9
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command15 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*1.9
					player.Character.Humanoid.BodyHeightScale.Value = BHS*1.9
					player.Character.Humanoid.BodyProportionScale.Value = BPS*1.9
					player.Character.Humanoid.BodyTypeScale.Value = BTS*1.9
					player.Character.Humanoid.BodyWidthScale.Value = BWS*1.9
					player.Character.Humanoid.HeadScale.Value = HS*2
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end

			if msg == Command16 then
				pcall(function()

					player.Character.Humanoid.AutomaticScalingEnabled = false
					wait()
					player.Character.Humanoid.BodyDepthScale.Value = BDS*2
					player.Character.Humanoid.BodyHeightScale.Value = BHS*2
					player.Character.Humanoid.BodyProportionScale.Value = BPS*2
					player.Character.Humanoid.BodyTypeScale.Value = BTS*2
					player.Character.Humanoid.BodyWidthScale.Value = BWS*2
					player.Character.Humanoid.HeadScale.Value = HS*2
					wait()
					player.Character.Humanoid.AutomaticScalingEnabled = true

				end)
			end 
		end)
	end)
end)


Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Something like this should work (it has been tested).

-- Services
local Players = game:GetService("Players")

-- Variables
local playerScales = {}
local maxScale = 5 -- set to a number to limit scale
local minScale = 0.5 -- set to a number to limit scale
-- set either to "nil" to disable the max or min scale

-- Functions
local function onPlayerAdded(player)
	local function onCharacterAdded(character)
		playerScales[player] = {}
		local humanoid = character:WaitForChild("Humanoid")
		if humanoid then
			for _, numberValue in pairs(humanoid:GetChildren()) do
				if numberValue:IsA("NumberValue") then
					playerScales[player][numberValue.Name] = numberValue
				end
			end
		end
	end
	if player.Character then
		onCharacterAdded(player.Character)
	end
	player.CharacterAdded:Connect(onCharacterAdded)

	player.Chatted:Connect(function(message)
		if string.lower(string.sub(message, 1, 6)) == "!scale" then
			local value = tonumber(string.sub(message, 8))
			if value ~= nil then -- it's a number
				if maxScale and value > maxScale then
					value = maxScale
				elseif minScale and value < minScale then
					value = minScale
				end
				for _, scaleValue in pairs(playerScales[player]) do
					scaleValue.Value = value
				end
			end
		end
	end)
end

-- Events
for _, player in pairs(Players:GetPlayers()) do
	onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)

Edit: @BSIncorporated beat me to it but I did also add a minScale and maxScale variable if you want to set those.

Gif: https://gyazo.com/ae1f4cc7deafc51f74959d8b6eef95a1

3 Likes

Hello,

I think I can help you not only fix your issue, but make your script a lot more customizable, and help you avoid copy and pasting for every value.

Using string.sub instead of listing all the possible !scale commands makes the script MUCH more customizable. string.sub returns only part of a giving string based on the parameters given. For example: string.sub("Hello World",1,5) will return “Hello” as I have only allowed for 5 letters to pass through.

local minScale = 0.5 -- Now you can set a minimum size in case you wanted to change it in the future
local maxScale = 2 -- Now you can set a maximum size in case you wanted to change it in the future

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(chr)
		player.Chatted:Connect(function(msg)
			
			local BDS = player.Character.Humanoid.BodyDepthScale.Value
			local BHS = player.Character.Humanoid.BodyHeightScale.Value
			local BPS = player.Character.Humanoid.BodyProportionScale.Value
			local BTS = player.Character.Humanoid.BodyTypeScale.Value
			local BWS = player.Character.Humanoid.BodyWidthScale.Value
			local HS = player.Character.Humanoid.HeadScale.Value
			
			if string.sub(msg,1,7) == "!scale " then --I'm including the space to ensure they enter the command properly
				if tonumber(string.sub(msg,8)) then --checks if the rest of the message is a number
					local scale = math.floor(tonumber(string.sub(msg,8) * 10)) / 10 --This ensures that if the player enters a number like 1.2324232 that it just returns 1.2
						if scale < minScale then scale = minScale --If the player enters anything less than 0.5, it will act as if they entered 0.5
						elseif scale > maxScale then scale = maxScale --if the player enters anything larger than 2, it will act as if they entered 2
						end
						pcall(function()
							
							player.Character.Humanoid.AutomaticScalingEnabled = false
							wait()
							player.Character.Humanoid.BodyDepthScale.Value = BDS*scale
							player.Character.Humanoid.BodyHeightScale.Value = BHS*scale
							player.Character.Humanoid.BodyProportionScale.Value = BPS*scale
							player.Character.Humanoid.BodyTypeScale.Value = BTS*scale	
							player.Character.Humanoid.BodyWidthScale.Value = BWS*scale
							player.Character.Humanoid.HeadScale.Value = HS*scale
							wait()
							player.Character.Humanoid.AutomaticScalingEnabled = true
							
						end)
				end
			end
		end)
	end)
end)

There are other inefficiencies with the code you provided to us, but this should get you on the road to learning.

As I do not have a setup that would currently work with this script, please let me know if it gives any errors. Hope this helps!

1 Like

Wow, Thank you soo much. This solved my headache. It works perfectly!

Thank you soo much too this helps a lot! it worked perfectly too and that explanation of string.sub thought me a lot! thank you so much for helping me out!

Hey so I was retesting these scripts and when I tested yous the maxScale / minScale didn’t stop the player from going over the limit. idk if you could fix that because your script worked more efficiently by scaling the player

This line should prevent the player from going over the limit. I’m not entirely sure why that wouldn’t work…