Resize Character Script

Sorry for the vague title but a more accurate one would be stupidly long

local Scale = 0.1

script.Parent.Parent.TextButton.MouseButton1Down:Connect(function(clicked)

repeat

wait(0.01)

game.Players.LocalPlayer.Character.Humanoid.BodyWidthScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyWidthScale.Value + Scale

game.Players.LocalPlayer.Character.Humanoid.BodyDepthScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyDepthScale.Value + Scale

game.Players.LocalPlayer.Character.Humanoid.BodyHeightScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyHeightScale.Value + Scale

game.Players.LocalPlayer.Character.Humanoid.BodyProportionScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyProportionScale.Value + Scale

game.Players.LocalPlayer.Character.Humanoid.BodyTypeScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyTypeScale.Value + Scale

game.Players.LocalPlayer.Character.Humanoid.BodyWidthScale.Value = game.Players.LocalPlayer.Character.Humanoid.BodyWidthScale.Value + Scale
game.Players.LocalPlayer.Character.Humanoid.HeadScale.Value + Scale

until
game.Players.LocalPlayer.Character.Humanoid.BodyWidthScale.Value >= 6
end)

Alright so what I want is to know if there’s a more effective version of this script that changes all of the values of the scales instead of putting a seperate line in for each change, and I want to be able to scale the head a bit bigger or else the head will look unusually small if scaled to the same as the other values. I know another script could possibly handle the scaling but this seems a bit hacky and there must be another option.

5 Likes

Learn to use variables to shorten your code! All your declarations that start with game.Players.LocalPlayer.Character.Humanoid could be shortened to just a single word, such as Humanoid, with a variable assignment.
e.g:

local Humanoid = game.Players.LocalPlayer.Character.Humanoid
Humanoid.--[[property]].Value = Humanoid.--[[property]].Value + Scale

If you find this confusing with changing properties, remember that you should just reference the object that possesses the property, not the property itself, so that you get a reference and not a value passed to the variable.

Other than this, I would use a for loop with all the properties from the humanoid in a table of strings.

local Properties = {"BodyDepthScale", "BodyWidthScale", ...}

repeat
    wait(0.01)
    for _, property in pairs(Properties) do --fixed
        Humanoid[property].Value = Humanoid[property].Value + Scale
    end
until Humanoid.BodyWidthScale.Value >= 6

Edit: If you want to scale the head a bit bigger, you can take it out of the for loop, calculate it separately, and just apply a multiplier to Scale before adding it to the Head scale value.

9 Likes

local Properties = {“BodyDepthScale”, “BodyWidthScale”}

local Humanoid = game.Players.LocalPlayer.Character.Humanoid

local Scale = .1

script.Parent.MouseButton1Down:Connect(function(clicked)

repeat

wait(0.01)

for property in pairs(Properties) do

Humanoid[property].Value = Humanoid[property].Value + Scale

end

until Humanoid.BodyWidthScale.Value >= 6

end)
Doesn’t appear to be working in a local script under the text button.

Also, I never understood ipairs despite referring to the developer hub. You don’t have to but if you have the time could you break it down for me?

2 Likes

So,

  • When I was listing the Properties table, it was more like a really short example because I was really lazy. You have to include every property that you want to change in there as a string, which was why I included the ellipsis (...) at the end. Make sure not to have any typos in each string as well!
  • I also made a typo in the for loop, it’s supposed to be _, property, not just property, otherwise the for loop will loop through indexes, 1, 2, 3,..., #Properties, instead of the actual strings.
5 Likes

I guessed the “…” one but thank you for the informing me about the typo! Greatly appreciated. Gonna try it now

Needed to make the script wait for the humanoid(my own fault) thank you!

2 Likes

The script isn’t working anymore, is there a new version of it?

1 Like

This post if from 2 years ago, so i think.

Are you using a local script?

1 Like

no, I’m creating a boss in a zombie game and it has to be bigger that the others. It’s a server script!

1 Like

You need to use a local script.
Indexing LocalPlayer requires a local script.

1 Like

Sure, but I’m not using Local Player. My server script is in the charater:

script.Parent.Humanoid

is what replaces

game.Players.LocalPlayer

in my case.

2 Likes

Idk if you fixed it or not, but just in case. If you’re looking to just have a big boss, scale it in studio with the scaling tool. I’ll try to see if NPCs are scalable as I’m not sure

Edit: also make sure the humanoid inside the NPC contains these
image

1 Like