Resizing gui, problem

local skillTree = script.Parent
local gui = script.Parent.Parent

game:GetService("UserInputService").InputChanged:Connect(function(input)
	if (input.UserInputType == Enum.UserInputType.MouseWheel) then
		local mouseWheel = Enum.UserInputType.MouseWheel
		if skillTree.Visible == true then
			while true do
				task.wait()
				skillTree.Size = UDim.new(script.Parent.Size.Width.Scale, script.Parent.Size.Width.Offset + mouseWheel)
			end
		end
	end
end)

So here I have a script, my task is to make sure that when the player rolled the mouse wheel frame size either decreased or increases, what is wrong with my script? As I understand it, I do not resize correctly, but how should I?

Are you getting any errors in the console? If so, make sure to let me know about them. Also, you can’t use a UDim for scaling a GUI, even if you only need to scale the Width. Instead, use a UDim2 like so:

skillTree.Size = UDim2.new(script.Parent.Size.Width.Scale, script.Parent.Size.Width.Offset + mouseWheel,script.Parent.Size.Height.Scale,script.Parent.Size.Height.Offset)

Additionally, if you’re going to add a scrollable GUI, i’d recommend you to use a ScrollingFrame instead, as it handles scrolling positions automatically.

Try this

local skillTree = script.Parent
local gui = script.Parent.Parent

game:GetService("UserInputService").InputChanged:Connect(function(input)
	if (input.UserInputType == Enum.UserInputType.MouseWheel) then
		if skillTree.Visible == true then
			skillTree.Size = UDim2.new(0,skillTree.Size.X.Offset+input.Position.Z,0, skillTree.Size.Y.Offset+input.Position.Z)
		end
	end
end)