Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
ekweji 4
7 years ago
Edited 7 years ago

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

Log in to vote
1
Answered by
duckwit 1404 Moderation Voter
7 years ago
Edited 7 years ago

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)
0
I thought an local script was only for GUIs and Tools, but thank you and I accept this answer. ekweji 4 — 7y
0
Actually nevermind still not working ekweji 4 — 7y
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. duckwit 1404 — 7y
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...) duckwit 1404 — 7y
Ad

Answer this question