Find ProximityPrompt that activated gui from script in gui

  1. What do you want to achieve?
  • I want to locate the ProximityPrompt that activated the gui, so that I can access the model
  1. What is the issue?
  • I don’t know how to achieve this
  1. What solutions have you tried so far?
  • I made a ui that shows up when activating the ProximityPrompt
  • The ui is a Textbox and when you press submit I want to put that text inside something in the model
  • But for that to work I need to locate the ProximityPrompt that started it all
  1. Kind Regards,
    LikeMyDeathNote.

Can’t you check the name of each proximityprompt to know which one of them was triggered?

or check the name of the parent

TLDR: I failed at helping dont even try it. I gotta learn more lua

Ok so what you could do is call a remote event and pass through an object value as an argument.

So an example is

Stuff for server script
note: you have to make this script a child of wanted proximity prompt

script.Parent.Triggered:Connect(function(plr)
local ev = game:GetService("ReplicatedStorage").MyRmEvent
local ObjVal = Instance.new("ObjectValue")
--adding the proximity prompt as the value of ObjVal
ObjVal.Value = script.Parent
ev:FireClient(plr, ObjVal)
)

local script for Gui

local event = game:GetService("ReplicatedStorage").MyRmEvent
event.OnClientEvent:Connect(function(prompt)
print(prompt.Name)
print("If above said the name of wanted prompt then i did it right!")
)

I apologize if this does not work. This is my first time working with lua in 2 months. I have been doing a lot of html and css recently.

no problem I shall try it out!
sorry for the late response I had to make Dinner

Kind Regards,
LikeMyDeathNote.

  • I can’t I have to use a lot of models and its too complex to give each one its own script to function properly
  • But help is always appreciated!
local function onPromptTriggered(promptName)
	--Do code depending on which prompt was triggered.
end

for _, prompt in ipairs(workspace:GetDescendants()) do
	if prompt:IsA("ProximityPrompt") then
		prompt.Touched:Connect(function()
			onPromptTriggered(prompt.Name)
		end)
	end
end

You just need to give each prompt its own way so that it can be uniquely identified.