Proximity Prompt Problems

:question: So I’m trying to make it so a GUI opens from a Proximity prompt, however I’ve tried so many different scripts, it seems essentially impossible.


I've tried using a script (similar) to this which would run on the serverside which would give the error: "Player Arguement must be a Player Object"
PopupFolder = game.ReplicatedStorage.Popups

script.Parent.ProximityPrompt.Triggered:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
		PopupFolder.Sawmill.Leave2:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
	end
end)

I then tried using a local script in which a breakpoint at the beginning wouldn't even trigger:
script.Parent.ProximityPrompt.Triggered:Connect(function(hit)

game.Players.LocalPlayer.PlayerGui.Popups.Start.Visible = true

game.Players.LocalPlayer.PlayerGui.Popups.GUISounds.Stepped:Play()

end)

:thinking: What I’m wondering is how I could fix the script (whether local or server) to make it so the GUI from a proximity prompt.

2 Likes

Proximity prompts are handled on the server whereas player guis are handled on the client. You need to make a remote event that is fired to the client when a proximity prompt is triggered. see here for proximity prompt events: ProximityPrompt (roblox.com) and here for handling remote events: Remote Functions and Events (roblox.com)

1 Like

To make a gui appear after a proximity prompt is triggered you will need a script, local script, and a remote event. I quickly made a demo project which I have attached. Simply put, when you trigger the proximity prompt the server script triggers the remote event, which then triggers the local script to make the gui visible.

Proximity Prompt & GUI Demo.rbxl (32.6 KB)

1 Like

The simplest way to achieve this is to have a “ScreenGui” instance be cloned into the player’s “PlayerGui” folder when that particular player triggers a prompt.

local Prompt = script.Parent

local Server = game:GetService("ServerStorage")
local Gui = Server.ScreenGui

Prompt.Triggered:Connect(function(Player)
	local GuiClone = Gui:Clone()
	GuiClone.Parent = Player.PlayerGui
end)

image

2 Likes