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!
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