ClickDetector giving diffrent inputs based on tool in hand

I want to make my value change based on what tool im clicking with but i cant even click the button while holding it out my code looks like this (first i click then pull out the tool and it dissapears) and heres how i want it to work (https://gyazo.com/a4fa6719980824c7be0dc181007469da)

local cauldron = game.Workspace.cauldron
local value = cauldron.IngredientValue

button.MouseClick:Connect(function(player)
	local char = player.Character
	local scroom = char:WaitForChild("Scroom")
	if scroom then
		value.Value = value.Value ..",Scroom"
        scroom:Destroy()
	end
end)

Replace “WaitForChild” with “FindFirstChild”

click detectors do not work while holding a tool
use this to figure out how to fix

a few suggestions on how you detect the tool too
shouldnt use :WaitForChild() this will slow down the script a lot. use :FindFirstChild() and check if it exists
also make sure the character exists before checking for stuff in it because the character may not exist (happens to me a lot)

1 Like

so i dont need the clickdetector entirely?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.