The problem I have right now is when I equip a key and try to click the lock, it doesn’t do anything, but when I unequip it, the script works. I first used the script below but it didn’t do anything when I had the key equipped so I practically deleted it. Did some research and found this topic https://devforum.roblox.com/t/how-to-make-a-door-with-click-detector-key-instead-of-touched-function/1274608 but it didn’t help me out either since they said if you use the Activated event, ClickDetectors would not work. So I’m confused on what I should do?
local function ClickDetectorClicked(player)
if player.Character and player.Character:FindFirstChild("ToolName") or player.Backpack:FindFirstChild("ToolName") then
print("valid")
end
end
part.ClickDetector.MouseClick:Connect(ClickDetectorClicked)
local function ClickDetectorClicked(player)
if player.Parent:FindFirstChild("ToolName") or player.Backpack:FindFirstChild("ToolName") then
print("valid")
end
end
script.Parent.ClickDetector.MouseClick:Connect(ClickDetectorClicked)
try this and replace clickDetector with ProximityPrompt
local function ClickDetectorClicked(player)
if player.Character:FindFirstChild("ToolName") or player.Backpack:FindFirstChild("ToolName") then
print("valid")
end
end
script.Parent.ProximityPrompt.MouseClick:Connect(ClickDetectorClicked)
try this and replace ClickDetector with ProximityPrompt it way work for you
local function ClickDetectorClicked(player)
if player.Character:FindFirstChild("ToolName") or player.Backpack:FindFirstChild("ToolName") then
print("valid")
end
end
script.Parent.ProximityPrompt.Activated:Connect(ClickDetectorClicked)
The problem is when you equip a tool and try to interact with an object has ClickDetector in it, it won’t work. Because the tool blocks out the mouse communication with the ClickDetector. At the moment, there is no properties to disable that. Best you can do is to make a fake ClickDetector by using Mouse.Target checks for the model’s name and do stuff.