Hi there,my name is Leon and I am very new at scripting,I have been trying to change a player’s size when they touch a part with any of their body parts.
I have tried looking for videos for this,but I can’t seem to find them,if you could help me I would highly appreciate it!
local HS = Humanoid.HeadScale
local BDS = Humanoid.BodyDepthScale
local BWS = Humanoid.BodyWidthScale
local BHS = Humanoid.BodyHeightScale
HS.Value = HS.Value * 2
BDS.Value = BDS.Value * 2
BWS.Value = BWS.Value * 2
BHS.Value = BHS.Value * 2
You can change the scale of the player with the Scale properties in the Humanoid. The default scale size is 1. Remember that Roblox allows players to slightly modify their body proportions in Avatar selection, so if you plan to revert the player you will need to store their current values.
I inserted what you said into a script,but the ‘‘Humanoid’’ has got a red underline in it and when I try to step into the part it doesn’t change the size of my character
if game.Players:GetPlayerFromCharacter(hit.Parent)
then HS.Value = HS.Value * 2
BDS.Value = BDS.Value * 2
BWS.Value = BWS.Value * 2
BHS.Value = BHS.Value * 2
end
end)
This is what I used but it still doesn’t work,did I type something wrong?
I tried to say local Humanoid = Player.Character.Humanoid but it couldn’t find it so I wrote local Humanoid = game.Players.Humanoid
Why why you try to get the player’s Scale before they touch the part? Assuming this is a server script, you can only get the player once they touch the part.
local part = game.Workspace.Part
part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.HeadScale.Value *= 2
Humanoid.BodyDepthScale.Value *= 2
Humanoid.BodyWidthScale.Value *= 2
Humanoid.BodyHeightScale.Value *= 2
end
end)
Edit: Updated code to use the newly added compound assignments.
Thank you for this,I am new and you clearly know way more than me lol,the script works well but when I go giant it makes me way too big and it throws me out the map. Is there any function or solution to prevent a certain size?
All of this information you have asked for is very easy to find with a quick google search. You can make use of a debounce to limit how often the code runs.
To prevent getting too big, simply add an if statement, making sure the scale is below a certain value.
You’re not limited to the Scale * 2 that I gave in the example script. You can change the numbers how ever you want with basic math.
what if i wanted to keep his proportions? like for example, a skinny avatar, going with the normal humanoid scales it will make it more chubby. i tried
edit: nvm i just found out lol
local x = .5 --resize factor
hum.BodyWidthScale.Value *= x
hum.BodyDepthScale.Value *= x
hum.BodyHeightScale.Value *= x
hum.HeadScale.Value *= x