ProximityPrompt Help

Hello, DevForum

How to make a ProximityPrompt disappear when someone Triggers it, but when they rejoin, it is back there to be used. Pretty simple, but I am pretty new to the developing world and could use some help.

Thank you.

1 Like

do you want it client sided, or server sided?

Client Sided, Sorry i was less specific

--In a local script
local PP = --Your proximity prompt goes here

PP.TriggerEnded:Connect(function()
  PP:Destroy()
end
--This destroys it on the client, and when you rejoin it reappears since it was only done on your client.

oh its fine, it don’t change too much

local script:

script.Parent.Enabled = true
script.Parent.Activated:Connect(funciton() --i think its activated btw, if its not just change it
script.Parent.Enabled = false
end)
1 Like

that works too, and its probs the best way to do it*

Your way is a good way too but i would recommend you separate variables and functions so it looks more clean
Example:

script.Parent.Enabled = true
script.Parent.Activated:Connect(funciton() --i think its activated btw, if its not just change it
script.Parent.Enabled = false
end)
--Original code

script.Parent.Enabled = true

script.Parent.Activated:Connect(funciton() --i think its activated btw, if its not just change it
   script.Parent.Enabled = false
end)
--new one

But it doesnt really matter do it the way you fell better with!

1 Like

Would these reset once the player rejoins? Like the PP is back?

yeah, both do that, but do shadows way, its way better
(and cleaner)

1 Like

I will update you all on if it works tomorrow

that works too, i wrote it in devforums, and i dont really care about formatting (but thanks)

Here is another way you can go about doing this also if you want it to be disabled for all players if one player triggers it, but then if the player who triggered it leaves, it will come back for all players:

  1. Create a BoolValue within the part that has the prompt and name it “Triggered”
  2. Within the PP, insert a serverscript
local proximityPrompt = script.Parent

-- Function to enable/disable proximity prompt based on property values
local function updateProximityPrompt()
	if script.Parent.Parent.Triggered.Value == true then
		proximityPrompt.Enabled = false
	else
		proximityPrompt.Enabled = true
	end
end

--Trigger the prompt
script.Parent.Triggered:Connect(function(plr)
if plr then
script.Parent.Parent.Triggered.Value = false
--Whatever you're intending to do! Just as long as you make the Triggered bool = false.
end
		updateProximityPrompt() 
end)

-- PlayerRemoving event handler
game.Players.PlayerRemoving:Connect(function(player)
		-- Reset plot values
		script.Parent.Triggered.Value = false

		updateProximityPrompt() -- Update proximity prompt state
	end
end)

-- Initial update of proximity prompt state
updateProximityPrompt()

Hope this was useful in someway :slight_smile:

1 Like

I tried to put in all your scripts in a local script. The PP is supposed to put a tool in the player’s backpack, but it says the “Tool isnt a valid member of ServerStorage”. Any way to get around this?