Help with player.Hit = open gui

so, i made a simple script, I do not know much about this script but it isn’t working.

it is placed in a part

why isn’t it working, it doesn’t show any errors?

script:

script.Parent.Touched:connect(function (hit)
 if hit.Parent and game.Players:FindFirstChild(hit.Parent.) then
 local plr = game.Players[hit.Parent.] then Script.Parent.StarterGui.SecretAdmin.Enabled = true
			
 end
 end
end)```
1 Like

Players get a copy of the gui from StarterGui when they join the game. You should be modifying the gui inside of the player’s PlayerGui instead of the StarterGui

Please add Debounce ( thats not your script problem )

the problem is you are enabling gui in startergui instead of playergui.

local db = true
script.Parent.Touched:connect(function (hit)
      if hit.Parent:FindFirstChild("Humanoid") then
     if db then
         db = false
         local player = game.Players:GetPlayerFromCharacter(hit.Parent)
         player.PlayerGui.SecrectAdmin.Enabled = true
         wait(.4)
         db = true
        end
     end
end)

I’m confused, is this in a local script?

If so then, type this:

local secretAdmin = script.Parent.SecretAdmin -- Or where ever your "Secret Admin" is located

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		secretAdmin.Enabled = not secretAdmin.Enabled -- When the player touches it, it will appear. And then when the player touches it again, it will disappear.
	end
end)

Let me know if this helps!
script.Parent.Touched:connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if Player then
		local Gui = Player.PlayerGui:FindFirstChild("SecretAdmin")
		if Gui then
			Gui.Enabled = true
		end
	end
end)