Hi, I'm trying to create a part that can be triggered via proximity prompt, but needs a key tool either in the backpack or equipped on the character, this is the code:
'''lua
local keybutton = script.Parent
local prompt = keybutton.ProximityPrompt
local key = game.Workspace.Key
local handle = key.Handle
prompt.Triggered:Connect(function(player)
if player.Backpack:FindFirstChild("Key") or player.Character:FindFirstChild("Key") then
print("Success")
else
print("Fail")
end
end)
'''
it works if it's not equipped and is in the backpack but it prints nothing if the player equips it, this code is reused from another part that works the same way, however that one works, this is the code:
'''lua
local cooler = script.Parent
local prompt = game.Workspace.cooler.ProximityPrompt
local coolant = game.Workspace.coolant
local handle = coolant.Handle
prompt.Triggered:Connect(function(player)
if player.Backpack:FindFirstChild("coolant") or player.Character:FindFirstChild("coolant") then
print("Filled")
else
print("You do not have any coolant")
end
end)
'''
this code works, but the key one doesn't.
Any help is appreciated thank you!