GUI not disabling

So “starter.Enabled = false” – That is the script that doesn’t work
“local starter = game:GetService(“StarterGui”):WaitForChild(“ScreenGui”)” – That is the issue
I am sure this is an easy fix but I’m just dumb.

–Script
local starter = game:GetService(“StarterGui”):WaitForChild(“ScreenGui”) – Issue with this
local button = script.Parent – Works

button.MouseButton1Click:Connect(function() – Works
if button == button then – Works
print(“yes”) – works
starter.Enabled = false – Doesn’t work
end
end)

You need to disable the GUI inside the LocalPlayers PlayerGui

task.wait(3)
local GUI = game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local button = script.Parent

button.MouseButton1Click:Connect(function()
GUI.Enabled = false 
end)
4 Likes

I got an error saying " PlayerGui is not a valid member of Players “Players”

It errors probably because the script runs before the Player fully loads into the game, add a task.wait(3) at the beginning of the script.

1 Like

Odd. I put in print statements and I still get the same error. "PayerGui is not a valid member of Players “Players”

Oh sorry my mistake forgot to put LocalPlayer after game:GetService(“Players”) in the Script, i edited the script for you it should work now.

2 Likes

Thanks for the help. I really appreciate it

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