Hi! I am developing right now a "Self Check in" for an airport, I've built the "Check In Station" with a part so it will look like a screen. The Gui is located in the StarterGui and named "CheckInGUI", while the screen part is located in: Workspace > Self Check In > Screen, Inside the screen I have a click detector. How do I make it so when I am clicking on the screen, the gui shows up?
COMMUNITY QUESTION
How to show a gui when clicking on a part?
2 answers
To be able to click on a part you need to add a ClickDetector to your part. Right click your part and then click Add object. After this find ClickDetector and add it to your part. Now here is what the script should look like:
local partClick = game.Workspace.SelfCheckIn.ClickDetector --// "Self Check In" would be better off as "SelfCheckIn"
local checkInGui = game:GetService("StarterGui").CheckInGUI
partClick.MouseButton1Clicked:Connect(function()
checkInGui.Enabled = true --// you could do this if you disabled it to hide it from other players or you could do
checkInGui.Frame.Visible = true --// the "Frame" to be renamed as whatever it is called.
end)
I think this will work. I'm not quite sure as I am not professional and i started last month but it looks ok to me.
The answer above me was almost right. Here is their script with the changes (put in a script in the screen and make sure there is a click detector in the Screen.)
local partClick = game.Workspace.SelfCheckIn.Screen.ClickDetector
local checkInGui = game:GetService("StarterGui").CheckInGUI
partClick.MouseClick:Connect(function()
local n = script.Parent.ClickDetector
n:Destroy()
workspace.GuiOpened:FireClient()
local o = Instance.new("ClickDetector")
o.Parent = script.Parent
end)
Put this in a local script in StarterGui:
workspace:WaitForChild("GuiOpened").OnClientInvoke:Connect(function(plr)
if plr then
plr.PlayerGui.CheckInGui.Enabled = true
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
