How could I locate the other player's proximityprompt so players could interact with each other

Disclaimer
I am new to scripting and been teaching myself through Dev forum, Roblox dev, and Youtube tutorials.
I always try to look and I usually find an answer, but couldn’t this time.

  1. What do I want to achieve?

I want to be able to add a function to a proximityprompt that is located inside of
another player and activates when “player a” triggers “player b” proximityprompt.

(The proximityprompt is inside of their humanoidrootpart)
(The RemoteEvent is in ReplicatedStorage)
(The Local Script is in StarterPlayerScripts)

  1. What is the issue? Video below

The issue I am having is that I don’t know how to locate the proximityprompt inside of another player in the game or how to tell when “player a” triggers “player b” proximityprompt.

https://gyazo.com/7c519b975b2b603466cbf67d030a4d1e

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve look on Developer Hub already and to no avail I found nothing.

I used a remote function for when the player triggers the proximityprompt it will simply print “Hey Server” and the server would print “Hey Client”. However when I go to test, absolutely nothing happens. I don’t get any errors in output. I believe that it has to do with the fact that I’m not getting the right proximityprompt, but I’m not sure.

Both my Local and Server script below

(Server Script)


local replicatedStorage = game:GetService("ReplicatedStorage")

local ContactPlayerRemote = replicatedStorage:WaitForChild("ContactPlayer")

local function proximityPromptTrigger(player)
	print("Hey Client")
end

ContactPlayerRemote.OnServerEvent:Connect(proximityPromptTrigger)

(Local Script)



local replicatedStorage = game:GetService("ReplicatedStorage")

local proximityPrompt = replicatedStorage:WaitForChild("ProximityPrompt")

local ContactPlayerRemote = replicatedStorage:WaitForChild("ContactPlayer")

ProxmityPrompt.Triggered:Connect(function()
	print("Hey Server")
	ContactPlayerRemote:FireServer(player)
end)

Summary
I just want to know how to get the other player’s proximityprompt (which I don’t know how to script), and how to let the server know when “player a” trigger “player b” proximityprompt.

This is my first post ever, so sorry in advance if I make mistakes. I don’t know how to go on about this, but I do appeciate all support!

1 Like

Try this

local replicatedStorage = game:GetService("ReplicatedStorage")

local ContactPlayerRemote = replicatedStorage:WaitForChild("ContactPlayer")

local function proximityPromptTrigger(player, triggeredPlayer)
	print("Hey Client")
end

ContactPlayerRemote.OnServerEvent:Connect(proximityPromptTrigger)
--Local Script
local replicatedStorage = game:GetService("ReplicatedStorage")

local proximityPrompt = replicatedStorage:WaitForChild("ProximityPrompt")

local ContactPlayerRemote = replicatedStorage:WaitForChild("ContactPlayer")

ProxmityPrompt.Triggered:Connect(function(triggeredPlayer)
	print("Hey Server")
	shockPlayerRemote:FireServer(triggeredPlayer)
end)

The triggeredPlayer is the one that triggered the proximity prompt, and the player is the one that fired the RemoteEvent.

1 Like

I made a slight error in the post with the “shockPlayerRemote” I meant to put “ContactPlayerRemote”, so sorry for that. I tried this and still see no messages in the output.

1 Like

Can you show us your current script?

1 Like

You’re connecting to a ProximityPrompt parented to ReplicatedStorage. It’s never going to be triggered.

Regardless, you almost don’t need any client code here and you don’t need a RemoteEvent. Insert a ProximityPrompt into StarterPlayer.StarterCharacterScripts and then listen to this event on the server:

Then on the client, destroy the ProximityPrompt parented to the local player’s character.

3 Likes

Nvm, i just noticed, that you shouldnt detect proximity prompt triggers if you want other players to trigger it. Also why are you referencing to trigger the ProximityPrompt from the Replicated Storage? Can you show us your script where you clone the proximityprompt?

Nvm someone answered first

Sorry for the late response. I understand what you saying, but it’s hard for me to grasp the idea.

I already have a setup to replicate a proximityprompt inside of replicatedstorage and parent it to the player in a server script. I just don’t know how in a local script to get another player’s proximityprompt. That’s why I setup the remote event for when “player a” trigger “player b” proximity prompt.

What I’m asking is, how do I make a variable or code inside a local script to get player b’s proximityprompt, so that “player a” could trigger it with “proximityPrompt.PromptTriggered” then fire the event.

Is it like I make a variable such as | local playersProx = otherplayers.proximityprompt (Just an example) |

Sorry if I make it confusing and don’t fully understand things.

I could show you the script I use to replicate the proximityprompt if you want still.

I don’t know how to reference the proximityprompt that’s located in another player because I’m new-ish at scripting, but how should I go on about this then if I shouldn’t detect the proximityprompt trigger with remotes.

I know you said the guy above answered my question, but it’s still confusing compared to the method I’m doing it at.

Yes. I fully understand what you’re asking, you don’t need to explain it to me. And I’m telling you that you don’t need to do this if the only thing you’re going to do with that information is fire a RemoteEvent.

You can just listen for the ProximityPrompt being triggered on the server with no RemoteEvent.

After looking back at your original post and reading the proximity thing a little more I got it. THANK YOU SOOOOO MUCH!!

1 Like