Help on resizing UI objects using scripts

Hi there, so I’m trying to scale a frame by using a script. And the way it’s supposed to work is if you left-click, it should resize the frame. It doesn’t work for some reason, but I knew I was pretty new when it comes to scaling/positioning UI objects using scripts. I did search for solutions in the DevForum and none of them seem to work.

Here’s the code:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gui = script.Parent
local frame = gui.Frame

	frame.Size +=, 0, 0, 1)

As you can see, it’s supposed to resize the frame and add 1 pixel ( or something, idk) when you left-click but it doesn’t resize it. I checked for errors in the output, it printed nothing.

frame.Size = frame.Size +, 0, 0, 1)

This may work I’m not sure. Isn’t += java?

I think so, but Roblox a few months ago added an update where you don’t have to do something like this:

thisvalue = thisvalue + anothervalue

You can now just do

thisvalue += anothervalue
1 Like

Oh wow I wish I knew they added it. I know I tried it like a year or two ago. Anyways I just did the frame.Size +=, 0, 0, 1) in studio and it worked for me so maybe one of your variables is wrong. Try putting a print in the event to make sure the event fires aswell.

1 Like

Alright so, here is my code and it works fine. If you want to try it out yourself then here is the file. Not sure why your way does not work since it works perfectly fine for me. Maybe you have a ui button in your way, since that when you press on it it Button1Down does not fire. (Also ignore the image button)

local mouse = game.Players.LocalPlayer:GetMouse()

script.Parent.Size +=,0,0,10)

ButtonResize.rbxl (24.8 KB)

They actually work both ways, see the thing is that the script I posted isnt the full code. And I just realized that the script I in my post works fine, its just in my full script I did spot some issues in the whole script itself and I was doing some debugging myself. But thanks anyway.

Ah, understood. No problem. Good luck!