Help with ProximityPrompt

I haven’t been developing for long, so the ProximityPrompt is new to me. I’ve read the documentation about it and used AI, but so far I haven’t found a solution.

Here is the problem: I want to make a GUI pop up after using the ProximityPrompt. This is what I used the script for:

local part = workspace:FindFirstChild("Part")
local proximityPrompt = part:FindFirstChildOfClass("ProximityPrompt")

if proximityPrompt then
	proximityPrompt.Triggered:Connect(function(player)
		print("Proximity Prompt von", player.Name, "ausgelöst")
		local playerGui = player:FindFirstChild("PlayerGui")
		if playerGui then
			local screenGui = playerGui:FindFirstChild("GUI for vehicle")
				local frame = screenGui:FindFirstChild("Frame")
				if frame then
					frame.Visible = true
					print("GUI sichtbar für", player.Name)

				end
			end
		end
	end)
else
	warn("ProximityPrompt nicht im Part gefunden!")
end


Basically, the script is working: I go to the part, activate the prompt, and it opens. I also have a button to close the GUI again with the script:

local Players = game:GetService("Players")
local player = Players.LocalPlayer 
local button = script.Parent 

button.MouseButton1Click:Connect(function()
	print("Button geklickt! Frame wird unsichtbar.")

	local playerGui = player:FindFirstChild("PlayerGui")
	if playerGui then
		local screenGui = playerGui:FindFirstChild("GUI for vehicle")
		if screenGui then
			local frame = screenGui:FindFirstChild("Frame") 
			if frame then
				frame.Visible = false 
				print("Frame für", player.Name, "wurde unsichtbar gemacht.")
			end

		end

	end
end)

But after closing it, it is not able to reopen. The frame does not set Visible = true after activating the prompt again. However, I do get the print statements that show me the function is launching, but it does not set the visibility to true. I also tried it on another game and it did also not work.

Any help or solution would be appreciated.

the problem is that the first script is server-sided and the second one runs on the client.

the server sees the frame’s property as Visible == true and so, it doesn’t update it again.

Simply change the first script to run on the client (or make it work in the second script)

2 Likes

Or make the first script fire a remote event that the second script recieves.

The server can’t handle gui, only the client can do that

The server, infact, can handle the player’s gui.
Using a remote event also requires the server which increases latency; it’s best to handle things like this fully on the client

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.