Shrink Humanoid On Touch Script: Help!

As you all know, as I’ve recently posted, I’ve created a few mini-builds that I may use as maps for a “mini” mini game. I’m not that great at scripting and I really need help, for now, to create a script to shrink the humanoid to fit on the map.
Can anyone give me any tips on how to shrink the humanoid on the touch of a block? An entire, fully written script is unneeded (your choice).

Here are the maps so far (planning on making a few, like an Arctic Valley and a Farmland map):

6 Likes

You know the avatar rescaling that Roblox implemented for every player to use? Well there’s some core code behind that, and the coders were nice enough to expose values to allow developers to change at will. You can find the specifics on that here. Anyways you would do something like this:

local scaleFactor = 0.5
part.Touched:Connect(function(part)
    --get player based on part
    player.Character.Humanoid.BodyDepthScale.Value = scaleFactor
    player.Character.Humanoid.BodyHeightScale.Value = scaleFactor
    --... and so on for BodyWidthScale and HeadScale
end)

Should rescale automatically. If it doesn’t, double check that Humanoid.AutomaticScalingEnabled is, of course, enabled.

5 Likes

adding on to this if you want them to scale relative to the old scale you can do

player.Character.Humanoid.BodyDepthScale.Value = player.Character.Humanoid.BodyDepthScale.Value * scaleFactor
4 Likes

a script in serverscriptservice


function PlayerSize(player)
 local SizeValue = 0.5
 
 local humanoid = player.Character.Humanoid
 if humanoid then
  if humanoid:FindFirstChild("BodyHeightScale") then
   humanoid.BodyHeightScale.Value = SizeValue
  end
 if humanoid:FindFirstChild("BodyWidthScale") then
  humanoid.BodyWidthScale.Value = SizeValue
  end
 if humanoid:FindFirstChild("BodyDepthScale") then
  humanoid.BodyDepthScale.Value = SizeValue
 end
 if humanoid:FindFirstChild("HeadScale") then
  humanoid.HeadScale.Value = SizeValue
  end
 end
end

wait(1)
for i, player in pairs(game.Players:GetPlayers()) do
 PlayerSize(player)
end
4 Likes

Thank you so much! I look forward to experimenting with this advice!

1 Like

:ok_hand:t2: Thanks! I’ll try out your advice.

1 Like

Is this a “On-join, shrink the humanoid” script?

2 Likes

Yes,it will work once they join,if not u can add that function

2 Likes

Ok! Thank you so much for your help! Can’t wait to try it out!

2 Likes

Quick question, what would the variable “player” represent?

2 Likes

its the player themself,so ican do player.Character

1 Like

so what should I put? the current code looks liek this

https://gyazo.com/cb8ca15e738278df38151d2e15b93822

2 Likes

i clicked on the link and it says that link is not accesible

1 Like


https://gyazo.com/24d232cc187b1fd4ef6e2a6cae4f198d

2 Likes

Delete all that and paste my code!

1 Like

Ok. I want an OnTouch code too, so players can choose whether or not to shrink. They can also see the difference in sizes of the map

2 Likes

Does your code work with R15? or R6 only?

1 Like

oh do this then

script.Parent.Touched:Connect(function(player)
 local SizeValue = 0.5
 
 local humanoid = player.Character.Humanoid
 if humanoid then
  if humanoid:FindFirstChild("BodyHeightScale") then
   humanoid.BodyHeightScale.Value = SizeValue
  end
 if humanoid:FindFirstChild("BodyWidthScale") then
  humanoid.BodyWidthScale.Value = SizeValue
  end
 if humanoid:FindFirstChild("BodyDepthScale") then
  humanoid.BodyDepthScale.Value = SizeValue
 end
 if humanoid:FindFirstChild("HeadScale") then
  humanoid.HeadScale.Value = SizeValue
  end
 end
end
end)

This is a script inside part

1 Like


https://gyazo.com/3b6cc1c6d66db837419d7d611bf53efe

there is an error at the end of the code. I think that is why it isnt working

2 Likes

take away a end ok Buddy ??!That should work

1 Like