Disabling PlayerGui

  1. What do you want to achieve? Keep it simple and clear!
    Disable a PlayerGui inside all players.
  2. What is the issue? Include screenshots / videos if possible!
    The script is not working
    i want delete this for a few seconds image|237x215
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes
--This is my script
local Player = game.Players.LocalPlayer
local playerGui = Player:WaitForChild("PlayerGui")
	while true do		
	playerGui.PlayerGui.KCoreUI.Visible = false
	wait(3)
end

Sorry if i made something wrong on this topic, its my first time making a topic.

Do you mean a screengui? They have a property called Enabled

1 Like

Just use .Enabled, don’t use .Visible.

I did it, but still dont works…

Change this line to this:

playerGui.PlayerGui.KCoreUI.Visible = false
to
playerGui.KCoreUI.Enabled = false

You got an extra PlayerGui, you don’t need it since you already declared it.

For this works i need put a LocalScript Inside StarterPlayer > StarterPlayerScripts, correct?

Yep, you can just also put it in StarterGui

Okay so If you want to disable all GUIs inside PlayerGui you can use this code:

local player = game.Players.LocalPlayer

for i, v in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
if v:IsA("ScreenGui") then
      v.Enabled = false
       end
end

This needs to be inside LocalScript!

1 Like

Sorry, i dont want delete everything from PlayerGui, just the “KCoreUI” from PlayerGui

Okay so If you want to disable only this GUI then:

local player = game.Players.LocalPlayer
local guitodisable = player:WaitForChild("PlayerGui").KCoreUI --your gui to be disabled

for i, v in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
if v:IsA("ScreenGui") and v.Name == guitodisable then
      v.Enabled = false
       end
end

It says theres a error on line 6

Can you show me the error please?

There would be no need to iterate through the playergui to find a specific screengui, you could simply do this

local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local kCoreUi = playerGui:WaitForChild("KCoreUI")
kCoreUi.Enabled = false
4 Likes

Can you please provide me with the screenshot of the script, I apologize I wrote it on mobile so there can be typo or something.

Sure

Oh my bad.

v.Enabled = false
1 Like

Thank you so much for the help :heart:

1 Like

I think it would be better if you insert a localscript in StarterGui and just do

local gui = script.Parent
local disableGui = gui:WaitForChild("KCoreUI")

disableGui.Enabled = false

This should work and is simpler to understand and should work too since the GUIS in StarterGui get cloned and parented to PlayerGui