0

# how would I make a proximity prompt do something depending on if they have a tool equipped?

hello, I am trying to make a game where if you have a tool equipped and you activate a proximity prompt then it will give you one outcome but if you don't have the tool equipped then it will give you a different outcome.

Here is the code inside the tool:

script.parent.Equipped:Connect(function()
_G.equipped = true
end)

script.parent.Unequipped:Connect(function()
_G.equipped = false
end)


Here is the code inside of the part with the proximity prompt:

script.Parent.ProximityPrompt.TriggerEnded:Connect(function(player)
if _G.equipped == true then
print("outcome 1")
else
print("outcome 2")
end
end)


If anybody could help, that would be great! Thanks!

0
Edited 5 days ago
local SpecificTools = {
YourToolName
}

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local character = player.Character

if character:FindFirstChildOfClass("Tool") then -- Checks if a player has a tool equipped.
if table.find(SpecificTools, character:FindFirstChildOfClass("Tool").Name) then
print("outcome 1")
else
print("outcome 2")
end
else
print("outcome 2")
end
end)


EDITED

0
Oh and i mispelled Triggered SEAN_YT213 104 — 5d
0
yea, I'm trying to make it for a specific tool so that prob wont help Borkingforlife 9 — 5d
0
I helped something with a similiar thing so ill edit my comment to that code SEAN_YT213 104 — 5d
0
I've edited it now. SEAN_YT213 104 — 5d