How do I make ClickDetector work when a player has a tool in their inventory?

I think the problem is that you have click detectors and proximity prompts in the same script.

what… i just fixed the script for you

local ToolA = script.Parent.Parent.Parent.StarterPack.ToolA
local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")

local object = script.Parent
local clickdetector = script.Parent.ClickDetector
clickdetector.MouseClick:Connect(function(player)
	if player then
        local char = player.Character or player.CharacterAdded:Wait()
        local tool = player.BackPack:FindFirstChildWhichIsA("Tool") or char:FindFirstChildWhichIsA("Tool")
    if tool and tool.Name == "ToolA" then
	    script.Parent.ProximityPrompt.Triggered:Connect(function(player)
		script.Parent.Transparency = 0.1
	end
    end
end)

Tell me if it errors.

If that was a thing he would’ve known idiot

I get these erros:


I’ve tried the code you provided and was able to get rid of the errors, yet nothing works.

This is the code with no errors:

local ToolA = script.Parent.Parent.Parent.StarterPack.ToolA
local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")

local object = script.Parent
local clickdetector = script.Parent.ClickDetector
clickdetector.MouseClick:Connect(function(player)
	if player then

	end
	local char = player.Character or player.CharacterAdded:Wait()
	local tool = player.BackPack:FindFirstChildWhichIsA("Tool") or char:FindFirstChildWhichIsA("Tool")
	if tool and tool.Name == "ToolA" then

	end
	script.Parent.ProximityPrompt.Triggered:Connect(function(player)
		script.Parent.Transparency = 0.1
	end)
end)

BRO JSUT COPY HIS CODE IT’S NOT HIS CODE YOUR JUST Trolling Ok

bro. are you trolling, i cant even tell

I’m sorry, I’m just really confused to why the code is not working.

Ok, don’t edit the code. When it errors I will fix it. Let me open studio to test it right quick.

Just copy the code he is sending if you troll again we are reporting

Ok i tested it and I found something that won’t error

local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")

local object = script.Parent
local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function(player)
	if player then
		local char = player.Character or player.CharacterAdded:Wait()
		local tool = player.Backpack:FindFirstChildWhichIsA("Tool")
		print(tool.Name)
		if tool and tool.Name == "ToolA" then
			script.Parent.Transparency = 0.1
		end
	end
end)

if that SOMEHOW errors then tell me, don’t edit it just send the error like you were doing. Also the proximityprompt is unneeded, you can remove it

No errors, but the part won’t change transparency

0.1 is a very slight shift, try 0.9 with this script:

local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")

local object = script.Parent
local clickdetector = script.Parent.ClickDetector

clickdetector.MouseClick:Connect(function(player)
	if player then
		local char = player.Character or player.CharacterAdded:Wait()
		local tool = player.Backpack:FindFirstChildWhichIsA("Tool")
		print(tool.Name)
		if tool and tool.Name == "ToolA" then
			script.Parent.Transparency = 0.9
		end
	end
end)


Still won’t change

.‘=’.
Use the clickdetector, don’t use the proximityprompt. If you want me to convert your tool to a proximityprompt tell me

Yeah, I’ll switch to click detector, can you help me with the code for that?

are you absolutely messing with me right now bro

I made a huge mistake! I thought we were going for proximity prompt until I saw the code carefully. I got rid of proximity prompt and the code works!

ohhhhhhhhhhhh ok thank god, if that helped you please mark it as a solution or smt

also please don’t just ask for code, reasearch your topic and try different solutions before you post here

Thank you for sticking through and helping me. I gave you your Solution mark

2 Likes