So I have been trying to create a gui that opens when the player clicks the computer screen. I tried it myself and watched a few videos but for some reason, it still doesn’t work the way I want it. When the player clicks on the screen, the gui opens and I created a button that closes it whenever the player is done viewing it. However, when the player goes to click the screen again, it prints that the button was clicked in output but the gui doesn’t pop-up. Can someone help me fix this or give me tips? I’m really new the scripting BTW.
This is the local script that I put my gui inside of. I’m pretty sure this controls whether or not it pops up again or not. Not sure how I can change this so that if the gui is closed it can reopen once the brick gets reclicked.
local gui = script.ScreenGui
local ComputerScreenClickedEvent = game.ReplicatedStorage.Events.ComputerScreenClicked
Would I need a script in the clickdetector if I use this or not? My current script in the brick is:
local clickDetector = script.Parent
local ComputerScreenClickedEvent = game.ReplicatedStorage.Events.ComputerScreenClicked
local debounce = false
clickDetector.MouseClick:Connect(function(player)
if not debounce then debounce = true
ComputerScreenClickedEvent:FireClient(player)
print(player.Name… “Clicked the screen”)
wait(.1)
debounce = false
print(“Function can be used again”)
end
end)
YourPart = --The part you want to reference goes here
YourGui = --Same thing here
YourPart.ClickDetector.MouseClick:Connect(function()
YourGui.Visible = true
end)
This should help you. Please note this is a script not a localscript
For that part use PlayerWhoClicked to find the player who clicked
This is not a full script as Scripting Support is not to ask for scripts. It is for help with scripts.
function onClicked(playerWhoClicked)
local playerWhoClicked = playerWhoClicked
playerWhoClicked.PlayerGUI.GUI.Frame.Visible = true
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)