To begin with, StarterGui is just the storage place for all guis that are given to a player. When a player joins, all guis in StarterGui are replicated into their PlayerGui, resulting in each player having their own guis. If you want to check a specific player's PlayerGui, this must be done through a local script.
Secondly, the if statement only checks the visibility when the script first executes. If you want to check the visibility when any of the guis' visibility changes, you can use GetPropertyChangedSignal.
Thirdly, since you are moving the local script to be inside the gui (since local scripts can only run in areas local to each player), you will have to reference the part through workspace.
So, the resulting script might look something like this (if it was a LocalScript inside the ScreenGui):
local S = script.Parent
for _,Gui in pairs(S:GetChildren()) do
if Gui:IsA("GuiObject") then
Gui:GetPropertyChangedSignal("Visible"):Connect(function()
if S.S1.Visible == true and S.S2.Visible == false then
workspace.Part.Size = Vector3.new(1,8,1)
end
end)
end
end
Something like this might help as an outline. It checks each gui inside the ScreenGui for visibility change, and then checks if the specific guis are visible or not when it occurs.
Hope this helps!
1 comment
maybe the gui is the problem