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

My Gui Variable won't enable the HintGui in StarterGui?

My problem is this I tried to enable my Gui variable but it will not work?

Cdetector = script.Parent.ClickDetector
rp = game:GetService("ReplicatedStorage")
status = rp:WaitForChild("StoneValue")
Gui = game:GetService("StarterGui"):WaitForChild("HintGui")


Cdetector.MouseClick:Connect(function()
	status.Value = status.Value + 1
	--script.Disabled = true--
	Gui.Enabled = true
	--[[for i = 0.1,1,0.3 do
		script.Parent.Stone1.Transparency = i
		wait(.1)
		script.Parent.Stone2.Transparency = i
		wait(.1)
		script.Parent.Stone3.Transparency = i
	end--]]
	
end)

1 answer

You need to retrieve HintGui from the Player's own personal GUI, which is called PlayerGui and can be found under Player in the instance hierarchy.

When you change objects in StarterGui, you only change the properties of objects which will, at some point in the future, be cloned to each player (either when they spawn or when they join the game).

When you modify things in PlayerGui, you will be changing the actual GUI currently controlled by and displayed to a player.

EDIT: When you modify a Player's GUI, you have to have a reference to the Player whose GUI you want to modify.

ClickDetector supplies a reference to the player that performed the click as one of the parameters to the MouseClick event, so you can reference the Player's GUI like this:

Cdetector = script.Parent.ClickDetector
rp = game:GetService("ReplicatedStorage")
status = rp:WaitForChild("StoneValue")

Cdetector.MouseClick:Connect(function(player) -- <-- passed by MouseClick
    local Gui = player.PlayerGui:WaitForChild("HintGui")
    status.Value = status.Value + 1
    Gui.Enabled = true
end)

4 comments

0

I thought an local script was only for GUIs and Tools, but thank you and I accept this answer.

0

Actually nevermind still not working

0

What isn't working? Instead of using a LocalScript to reference the player, you can use the Player argument passed by the MouseClick event.

0

I've edited the answer to be more clear. For future reference, its much easier for us to help you if you provide more information about what isn't working. (What you have tested, what you expect to happen, etc...)

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