Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I cant change the size of a textbutton through script?


script:local player = game.Players.LocalPlayer
local playerUI = player:WaitForChild("PlayerGui")
local presettings = playerUI:WaitForChild("Settings")
local Settings = presettings:WaitForChild("Settings")
local graphics = presettings:WaitForChild("Graphics")
Graphics = script.Parent
Graphics.MouseButton1Up:Connect(function()
	graphics.Visible = true
	game.StarterGui.Settings.Settings.Controls.Size.X = {0,150}
	game.StarterGui.Settings.Settings.Controls.Size.Y = {0,28}
end)

1 answer

✓ Accepted answer

To change the X value of a Gui:

YourGui.Size.Scale.X = 1

From the look of it your script will possibly not work (I'm not quite sure), Instead do this if your script is not located under the Gui.

-- If your script isn't located in the "StarterGui" do this

local localPlayers = game.Players.LocalPlayer
local playerGui = localPlayers:FindFirstChild("NameGui") -- The name of your gui. 
local settings = playerGui.Settings

settings.Size.Scale.X = 1

However if it is a child of the Gui then

local settings = script.Parent
settings.Size.Scale.X

To change a gui's size <----

settings.Size = UDim2.new(1, 0, 1, 0) 

Fix for your script (Hopefully)

-- Player Variables
local player = game.Players.LocalPlayer
local playerUI = player:WaitForChild("PlayerGui")

-- Gui Variables
local settingsAncestor = playerUI:WaitForChild("Settings")
local settingsChild = presettings.Settings
local controls = settingsChild.Controls
local graphics = settingsAncestor.Graphics

local textButton = script.Parent -- Changed graphics to textButton

textButton.MouseButton1Click:Connect(function()
    graphics.Visible = true
    controls.Size = UDim2.new(0, 150, 0, 28)

end)

Your script is a bit messy, and I can't tell which gui you wamt the size yo be changed, also you didn't pay attentiom to what I've written about and didn't evem bothered to modify your script. Here, hopefully will fix it

28 comments

0

i want to chnge the size value of a textbutton

0

From the looks of your script, you want to change the X value of it's size. However you want to change the whole size, correct?

0

yes

0

Can you please use code block?

0

what is code block

0

Anyways I have edited it, try it, and let me know if there's an error

0

x cannot be assigned to

0

i dont want to change the size of gui i want to change the textbuttons size

0

Cam you please show me to whole script you constructed

0

Also usw code block

0

whats codeblock

0

Lemme edit my answer hold on

0

There

0

inside where

0

Inside the ~

0

lol sorry

0

thats my script

0

what do i do

0

I've edited it, try and see if it works

0

Tell me if any problem comes up

0

didnt work but didnt show error

0

Can you show me your gui path

0

For example: StarterGui > Settings.Settings.Controls

0

how

0

yeah tahts it

0

Alrighty then do you have a discord

0

grandmaster1o1#1515

0

Mines kei, accept it

This discussion is preserved as it was. New answers, comments, and votes are closed.