Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you Enable a Health gui with a button? Look inside to understand (GUI)

so i am making a fps game so i need a health gui but i don't want it to be seen before they press a gui Button and the health gui i just found is this:. https://web.roblox.com/library/3312512261/Health-Gui

Problem:

the script i made is not working No errors.

My Script:

local Health_gui = game.StarterGui.HealthGui

script.Parent.MouseButton1Click:Connect(function()
	Health_gui.Enabled = true
	
end)

Very simple code but as i said not working????

1 answer

You cannot access the Player's Gui directly through StarterGui. You must somehow access their PlayerGui.

If you want it to appear for one player, insert a LocalScript into the button, with the following:

local HealthGUI = script.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
	HealthGUI.Enabled = true
end)

With a server script in ServerScriptService, do:

for _,player in pairs(game.Players:GetPlayers()) do
	player.PlayerGui.HealthGui.Enabled = true
end

This discussion is preserved as it was. New answers, comments, and votes are closed.