How to disable a proximity prompt on ServerSide but not locally?

Thanks for all support and help.

  1. What do you want to achieve?
    I want to make it so that when a player holds a proximity prompt, it is visible to them but not to others.

  2. What is the issue?
    I have tried many ways to work with ProximityPromptService, but I haven’t been able to achieve the goal.

  3. What solutions have you tried so far?
    I have tried using remote events, one triggered when the host begins holding, and another when it ends. With a value, I look for the name of the player holding the prompt. If it turns out to be the host holding the prompt, the prompt will remain visible; otherwise, it won’t.

I have only found a forum post on disabling the entire ProximityPromptService option, but it’s not exactly what I’m looking for.

This is my script failure and a possible example of what I’m looking for.
[ONLY POSTED IMPORTANT SCRIPT PARTS, TELL ME IF DO YOU WANT A COMPLETE SCRIPT]

ServerScript Inside ProximityPrompt:

script.Parent.PromptButtonHoldBegan:Connect(function(plr)
-- *Indicate WhoIsRestoring*
RestoreEvents:WaitForChild("InputStarted"):FireAllClients()
end)

script.Parent.PromptButtonHoldEnded:Connect(function(plr)
-- *Remove Text from the WhoIsRestoring Value.*
RestoreEvents:WaitForChild("InputEnded"):FireAllClients()
end)

script.Parent.Triggered:Connect(function(plr)
-- *Remove Text from the WhoIsRestoring Value.*
RestoreEvents:WaitForChild("InputEnded"):FireAllClients()
end)

LocalScript:

RestoreEvents:WaitForChild("InputStarted").OnClientEvent:Connect(function()
	wait()
	if WhoIsRestoring.Value == game.Players.LocalPlayer.Name then
		WhoIsRestoring.Parent:WaitForChild("ProximityPrompt").Enabled = true
	else
		WhoIsRestoring.Parent:WaitForChild("ProximityPrompt").Enabled = false
	end
end)

RestoreEvents:WaitForChild("InputEnded").OnClientEvent:Connect(function()
	wait()
	WhoIsRestoring.Parent:WaitForChild("ProximityPrompt").Enabled = true
end)

If you can help me don’t forget to tell me! :slight_smile:

Why don’t you just check on all the clients and if they’re not the player who triggered it, then disable it

I made this a lot more complicated than I needed at first, but it was just a skill issue on my part.

Of course get your ProximityPrompt and two regular scripts, name one Handler, and name one LocalHandler.

Capture

However, we need to do something special for LocalHandler so that it works in Workspace, which involves setting the RunContext to Client. This allows it to work in the workspace, even though it still functions as a client script.

Capture

In the Handler/Server script we need to add this code:

local holder = script.Parent.Parent.Holder
local proximityPrompt = script.Parent

--Prompt Started
local function promptStarted(player)
	holder.Value = player.UserId
end

--Prompt Ended
local function promptEnded()
	holder.Value = 0
	print("promptended")
end

proximityPrompt.PromptButtonHoldBegan:Connect(promptStarted)
proximityPrompt.PromptButtonHoldEnded:Connect(promptEnded)

And we need to add the code that actually disables and enables the prompt from the client (This goes in the LocalHandler script).

local player = game.Players.LocalPlayer
local holder = script.Parent.Parent.Holder
local proximityPrompt = script.Parent

holder.Changed:Connect(function()
	if holder.Value == 0 then
		proximityPrompt.Enabled = true
	else
		proximityPrompt.Enabled = false
		
		if holder.Value == player.UserId then
			proximityPrompt.Enabled = true
		end
	end
end)

This works by detecting when a user uses the ProximityPrompt and stores their UserId in an integer value that we can access from the client script. We can tell if it’s 0 then it is not being used and we have access, if it is our UserId, we have access but no one else does, and if it isn’t our UserId and it’s not 0 then we do not have access, as someone else is using it.

I tried it in a 2 person server, tell me if you have any problems and I wish you the best of luck!