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

How Do You Make A GUI Visible When Clicking An Object That Is In The Workspace?

Asked by 6 years ago
Edited 6 years ago

I'm trying to figure out how to make a GUI turn visible when an object in the workspace is clicked. Is there a way to do so?

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Place this in a part with a ClickDetector

script.Parent.ClickDetector.MouseClick:connect(function(player)
    Sg = player.PlayerGui:WaitForChild("ScreenGui") --Gui name
    Sg.Enabled = true
end)
0
Can’t modify the PlayerGui from the server. User#19524 175 — 6y
0
I just ran this and it worked The_Pr0fessor 595 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

So you are wanting this.

local ClickDetector = script.Parent:FindFirstChild("ClickDetector")
-- Place a 'ClickDetector' in your part!

ClickDetector.MouseClick:Connect(function(click)
if click.Parent:FindFirstChild("Humanoid") then 
local char = click.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local gui = player.PlayerGui:FindFirstChild("NameOfGUI") -- Enter your GUI name here!

gui.Enabled = true

end
end)

U have to put this script in Part next to the ClickDetector! If script dont work message me! Feel free to accept my answer if I helped you! ;)

0
The MouseClick event returns the player, not the part... User#19524 175 — 6y

Answer this question