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):
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.
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
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)