I’ve been trying to make a gui open when the proximity prompt button is held on. Unfortunately
I couldn’t try to make it work after a bunch of script changes.
script:
local ProximityPromptService = game:GetService("ProximityPromptService")
local gui = script.Parent.Text
local function onPromptTriggered(promptObject, player)
gui.Enabled = true
end
Instead of putting your ScreenGui inside the proximity prompt, put it in StarterGui, since your Gui inside the proximity prompt won’t clone into your PlayerGui.
local player = game:GetService("Players").LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local TextGui = PlayerGui:WaitForChild("Text")
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function()
TextGui.Enabled = true
end)
Sorry for the really late reply, but I was able to make the script work via something else
but my next problem is that when I click the exit button I had made for the script it does
not seem to work nor display any error messages.
local ProximityPromptService = game:GetService("ProximityPromptService")
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent.ScreenGui
local exit = gui.Frame.TextButton
local c = gui:Clone()
local function onPromptTriggered(promptObject, player)
c.Parent = player.PlayerGui
end
exit.MouseButton1Click:Connect(function()
c:Remove()
end)
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
You only clone the Gui once at the start of the script’s execution meaning that when it’s destroyed c.Parent will error as c is a reference to nil. Clone and parent the gui inside the “onPromptTriggered” function.