I have some scripts to add something into the players backpack when the proximity prompt is triggered. I also made it so you can only have the script give you the tool if you don’t already have the tool. maybe that would help with this problem but I don’t know.
When I trigger the proximity prompt, I get other tools from other proximity prompt scripts, which I don’t want. I need a way for the service to know I’m talking about the proximity prompt that the script is inside of, instead of any proximity prompt. Is that possible?
Heres the code:
local ProximityPromptService = game:GetService("ProximityPromptService")
local ToolName = (script.Parent.Parent.ToolName.Value)
local Storage = game:GetService("ServerStorage")
local ProximityPrompt = script.Parent
local function onPromptTriggered(promptObject, Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
local Tool = Storage:FindFirstChild(ToolName)
if Tool and not Backpack:FindFirstChild(ToolName) then
local ToolClone = Tool:Clone()
ToolClone.Parent = Backpack
end
end
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
Thanks! Keep in mind I’m pretty new to scripting so if its a really easy fix, thats why.