Disabling ProximityPrompts for certain players

I am giving a proximity prompt to each player, in order to make some requests between players. Problem is, the player is detecting its own prompt. I have tried disablind it through a remote but this hasn’t been working out.

Server:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

Players.PlayerAdded:Connect(function(plr)
	local PromptEvent = nil
	plr.CharacterAppearanceLoaded:Connect(function(char)
		local ProxPrompt = Instance.new("ProximityPrompt")
		ProxPrompt.ObjectText = "Challenge"..plr.Name
		ProxPrompt.HoldDuration = 2
		ProxPrompt.Parent = char:WaitForChild("HumanoidRootPart")
		ReplicatedStorage:WaitForChild("DisablePrompt"):FireClient(plr, ProxPrompt)
	end)
end)

Client:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DisablePrompt = ReplicatedStorage:WaitForChild("DisablePrompt")

DisablePrompt.OnClientEvent:Connect(function(prompt)
	prompt.Enabled = false
end)

This is so funny because I’ve had to deal with the same problem today. Fortunately I found a solution!

In a local script, you want to detect anything that enters the player’s rootpart and disable it locally, meaning it appears disabled only to the player. Put this in StarterPlayerScripts and you’re good to go.

--< Services
local PlayerService = game:GetService('Players')

--< Variables
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local rootPart = Character:WaitForChild("HumanoidRootPart")
rootPart.ChildAdded:Connect(function(item)
	wait() -- the wait here IS IMPORTANT!
	if item:IsA("ProximityPrompt")  then
		item.Enabled = false
	end
end)
4 Likes

Considering the player object is automatically passed as an argument to any function connected to a triggered prompt event you can simply use the following:

local prompt = script.Parent

prompt.Triggered:Connect(function(plr)
	if plr.Name == "" then --some player name
		return --stop function
	else
		--do code
	end
end)

This ended up working, however, before the ChildAdded event, I was forced to check for any existing proximityprompts first.

If you haven’t already, ensure your events are checking if the player is allowed to use the proximityprompt in the first place since they can re-enable the proximityprompt due to it being local (or just fire the event lol).