UI Size script not resizing the UI

Good day, so I’ve been trying to fix this problem myself for a few months now. So here’s how the script was supposed to work: if I click a button — which in this case, the script’s parent — the script changes another UI’s size.
Here’s the script:

local gui1 = game.StarterGui.TheWholePC.Frame["File Explorer"]

script.Parent.MouseButton1Click:Connect(function()
	gui1.Size = UDim2.new(0.08, 0,0.122, 0)
	gui1.Position = UDim2.new(0.027, 0,0.046, 0)
end)

Reply if you need me to state more information.
Thank you.

1 Like

Why using StarterGui? Can you tell me?

1 Like

Try getting the playergui not the startergui

local Player = game.Players.LocalPlayer  -- get player here
local PlayerGui = Player.PlayerGui  -- need to get the playersgui not the starter gui
local gui1 = PlayerGui:WaitForChild('TheWholePC').Frame["File Explorer"] -- might not need the wait depends on script

script.Parent.MouseButton1Click:Connect(function()
	gui1.Size = UDim2.new(0.08, 0,0.122, 0)
	gui1.Position = UDim2.new(0.027, 0,0.046, 0)
end)

had to edit had misstype on game.players above

3 Likes

You’re using StarterGui. You want to get the player’s PlayerGui.
using,

local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

Use :WaitForChild because the PlayerGui might still be loading.

If you do StarterGui, it only updates on the server. The default size.

3 Likes

I’m still a beginner at scripting UIs.

@Nyonic I’ll try that, thanks for the correction on the player gui.
@DeltOof12345 I’ll just put this above the function script as variable. right?
Sorry for the late replies to these comments, I hadn’t seen them 'cause of timezones. Anyway, I’ll update this if it does work.

@Nyonic It worked! Thanks. Now, as for @DeltOof12345, their script might be helpful for future references.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.