I can't resize a player when they click my button

This is the script:

local button = script.Parent
local debounce = false – To prevent rapid clicking

local function onClick()
if debounce then return end – Ignore rapid clicking
debounce = true – Set debounce to true to prevent rapid clicking

local player = game.Players:GetPlayerFromCharacter(button.Parent)
local character = player and player.Character
local humanoid = character and character:FindFirstChildOfClass(“Humanoid”)

if humanoid then
local scaleProperties = {
“BodyDepthScale”,
“BodyHeightScale”,
“BodyProportionScale”,
“BodyTypeScale”,
“BodyWidthScale”,
“HeadScale”
}

  for _, scaleName in ipairs(scaleProperties) do
  	local currentScale = humanoid[scaleName]
  	local newScale = currentScale * 1.1
  	humanoid[scaleName] = newScale
  end

end

wait(1) – Wait for 1 second before allowing another click
debounce = false – Reset debounce after the delay
end
button.ClickDetector.MouseClick:Connect(function()
onClick()
end)

2 Likes

the code is a bit difficult to read, though not impossible. Aside from that, have you looked into HumanoidDescription?

Edit: Sorry, I should say the code is difficult to read because of the formatting @minerpro_2 .

1 Like

local button = script.Parent
local debounce = false – To prevent rapid clicking

local function onClick()
if debounce then return end – Ignore rapid clicking
debounce = true – Set debounce to true to prevent rapid clicking

local player = game.Players:GetPlayerFromCharacter(button.Parent)
local character = player and player.Character
local humanoid = character and character:FindFirstChildOfClass(“Humanoid”)

if humanoid then
– Adjust scale properties
humanoid.BodyHeightScale = humanoid.BodyHeightScale * 1.1 – Increase height scale by 10%
humanoid.BodyWidthScale = humanoid.BodyWidthScale * 1.1 – Increase width scale by 10%
humanoid.HeadScale = humanoid.HeadScale * 1.1 – Increase head scale by 10%
end

wait(1) – Wait for 1 second before allowing another click
debounce = false – Reset debounce after the delay
end

button.ClickDetector.MouseClick:Connect(function()
onClick()
end)

I tried this and it didn’t work, and I don’t know what you mean by formatting.

I mean you can add backticks to your code to make it easier to read.

Example:
Three of these → `

--This is code. Testing testing.
--Paste code in this sort of block to format.
--end with three more ```

now it’s done.

‘’'local button = script.Parent
local debounce = false – To prevent rapid clicking

local function onClick()
if debounce then return end – Ignore rapid clicking
debounce = true – Set debounce to true to prevent rapid clicking

local player = game.Players:GetPlayerFromCharacter(button.Parent)
local character = player and player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")

if humanoid then
	-- Adjust scale properties
	humanoid.BodyHeightScale = humanoid.BodyHeightScale * 1.1  -- Increase height scale by 10%
	humanoid.BodyWidthScale = humanoid.BodyWidthScale * 1.1  -- Increase width scale by 10%
	humanoid.HeadScale = humanoid.HeadScale * 1.1  -- Increase head scale by 10%
end

wait(1)  -- Wait for 1 second before allowing another click
debounce = false  -- Reset debounce after the delay

end

button.ClickDetector.MouseClick:Connect(function()
onClick()
end)
‘’’

Almost. Make sure to use backticks ` and not apostrophe ’

local debounce = false  -- To prevent rapid clicking

local function onClick()
	if debounce then return end  -- Ignore rapid clicking
	debounce = true  -- Set debounce to true to prevent rapid clicking

	local player = game.Players:GetPlayerFromCharacter(button.Parent)
	local character = player and player.Character
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")

	if humanoid then
		-- Adjust scale properties
		humanoid.BodyHeightScale = humanoid.BodyHeightScale * 1.1  -- Increase height scale by 10%
		humanoid.BodyWidthScale = humanoid.BodyWidthScale * 1.1  -- Increase width scale by 10%
		humanoid.HeadScale = humanoid.HeadScale * 1.1  -- Increase head scale by 10%
	end

	wait(1)  -- Wait for 1 second before allowing another click
	debounce = false  -- Reset debounce after the delay
end

button.ClickDetector.MouseClick:Connect(function()
	onClick()
end)
1 Like

Can you not just use

player.Character:ScaleTo(scale)

If it’s a normal model then yes, you can use scaleto() but, if it’s a humanoid model… then, no.

I am trying to resize a player when they click a button, and nothing is working.

local debounce = false  -- To prevent rapid clicking

local function onClick()
	if debounce then return end  -- Ignore rapid clicking
	debounce = true  -- Set debounce to true to prevent rapid clicking

	local player = game.Players:GetPlayerFromCharacter(button.Parent)
	local character = player and player.Character
	local humanoid = character and character:FindFirstChildOfClass("Humanoid")

	if humanoid then
		local description = humanoid:GetAppliedDescription()
		
		-- Increase all scale properties by 10%
		description.BodyDepthScale = description.BodyDepthScale * 1.1
		description.BodyHeightScale = description.BodyHeightScale * 1.1
		description.BodyProportionScale = description.BodyProportionScale * 1.1
		description.BodyTypeScale = description.BodyTypeScale * 1.1
		description.BodyWidthScale = description.BodyWidthScale * 1.1
		description.HeadScale = description.HeadScale * 1.1

		humanoid:ApplyDescription(description)
	end

	wait(1)  -- Wait for 1 second before allowing another click
	debounce = false  -- Reset debounce after the delay
end

button.ClickDetector.MouseClick:Connect(function()
	onClick()
end)

It doesn’t work, but I think I used what you ment? idk

I got it

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(player)
	local char = player.Character
	local human = char.Humanoid
	
	local depth = human:WaitForChild("BodyDepthScale")
	local height = human:WaitForChild("BodyHeightScale")
	local width = human:WaitForChild("BodyWidthScale")
	local head = human:WaitForChild("HeadScale")
	
	local properties = {depth, height, width, head}
	
while true do
	for i,property in pairs(properties) do
		wait(1)
		local changeBy = 1
		property.Value = property.Value + changeBy
	end
	end
end)```
1 Like

I don’t know why it’s not working. I am testing your code and neither the onClick() function, nor even the ClickDetector event are working at all.

Did the script have to be a child of the click detector?

Edit: Nevermind. That’s my fault. Your script is working fine.

Second edit: I realize that the problem is that you didn’t add the .Value to the scale properties.