Proximity Prompts between Two Players

I have proximity prompts parented to each character’s HumanoidRootPart and I was wondering how I could tell/call a function when two players have triggered each others’ prompts.
I would think it could be handled on the server but I haven’t been able to figure out a solution to this issue.

2 Likes

You can use this event to detect whether the proximity prompt has been triggered.

That’s not the issue. My problem as stated above is to detect when that event has fired between 2 players.

There is no such event, but you can create a value at which it stores the player’s username when the end event is fired. You can use this to detect whether both players have fired each other’s proximity prompts.

In the blog that @Dragonfable6000 posted, the parameters is the player who last triggered the prompt, using this information you could use the print statement and type out player.Name with no quotations to see the different players

Could you give an example? I already knew this information but couldn’t think of how to actually script it.

Well, you can create an array and store the player’s username, here’s a pseudocode you can go off of.

local playerPressed = {}

When proximity prompt is done
     insert player name that interacted to table
end

Here’s a documentation on tables if you want to know how to insert items Tables | Documentation - Roblox Creator Hub

How would it know who to pair with who though?

Actually, it might be a bit harder to obtain information from each other. Try doing this method instead.

Imagine you are the one to trigger the event

When TriggerEnded (playerThatTriggered [This is you])
     If playerThatTriggered's ProximityPrompt has a string object with the value of the owner of the triggered ProximityPrompt, then -- Check if the player you are triggering already interacted with you
          print("They are a pair")
     else
          Create string object
          Make string object value = playerThatTriggered Name
          Parent it to triggered ProximityPrompt
     end     
end

Bit hard to read because it’s not formatted properly, but I think I understand what it’s meant to say. I will try something similar to this.

Pretty simple system here but you can create a bool value or smth that turns true when its activated and shuts off after x seconds and the scripts can check those bool values for them to be true or not and based on that you can execute X code depending on how you want the scripts to read those values as. Lmk if this helps or doesnt.

I believe I got it working correctly now. I created an object value when the prompt is triggered and used an if statement to check if the other player had one for them.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.