Width/depth changing interferes with size changing

i have three scripts listed below together with a screenshot of the locations. what these scripts do is change the player clicking thems width or depth depending on what button they click. my game also involves alot of size changing and there comes the problem.

there is a min and max on width and depth. if u become the minimum depth ur pretty thin but not paper thing. if u shrink in the game then for some reason u do become paper thin. i think this has to do with the depth changing again when shrinking/ growing. is there anyway to make these not completely make players paper even when shrinking? (another example if depth is max and u shrink u become super duper fat.).

i have thought this a bit through and come to a solution, how about everytime i shrink/grow in size the depth and width resets according to my size. so if im the smallest size and add/substract width/depth and then grow again the width and depth resets to the normal width and depth id be at that size. ive also noticed the script has local min and max but maybe the min and max should change according to my size, because when im smallest size i cant substract width or depth anymore because the script thinks im already at min.
first 2 scripts: (depth)
minus


local increment = 0.2
local min = 0.6
local Click = Instance.new("ClickDetector")
Click.Parent = script.Parent

Click.MouseClick:Connect(function(d)
	local c = d.Character
	if c then
		local h = c:FindFirstChild("Humanoid")
		if h then
			local bws = h:FindFirstChild("BodyDepthScale")
			if bws.Value - increment >= min then
				bws.Value = bws.Value - increment
			end
		end
	end
end)

plus


local increment = 0.2
local max = 2
local Click = Instance.new("ClickDetector")
Click.Parent = script.Parent

Click.MouseClick:Connect(function(d)
	local c = d.Character
	if c then
		local h = c:FindFirstChild("Humanoid")
		if h then
			local bws = h:FindFirstChild("BodyDepthScale")
			if bws.Value + increment < max then
				bws.Value = bws.Value + increment
			end
		end
	end
end)

third script: (width)


local gr = script.Parent
local increment = 0.2
local max = 2
local mclick = gr:WaitForChild("Plus"):FindFirstChildOfClass("ClickDetector")

mclick.MouseClick:Connect(function(d)
	local c = d.Character
	if c then
		local h = c:FindFirstChild("Humanoid")
		if h then
			local bws = h:FindFirstChild("BodyWidthScale")
			if bws.Value + increment < max then
				bws.Value = bws.Value + increment
			end
		end
	end
end)

local min = 0.6
local pclick = gr:WaitForChild("Minus"):FindFirstChildOfClass("ClickDetector")

pclick.MouseClick:Connect(function(d)
	local c = d.Character
	if c then
		local h = c:FindFirstChild("Humanoid")
		if h then
			local bws = h:FindFirstChild("BodyWidthScale")
			if bws.Value - increment >= min then
				bws.Value = bws.Value - increment
			end
		end
	end
end)

locations:
image

1 Like