How i want my script to work is to add a value after i click on the part with a tool and tool dissapears
But it simply doesn’t work i click on the part with the tool in hand and nothing happens
Heres my script (Heres how i want it to work https://gyazo.com/a4fa6719980824c7be0dc181007469da)
local cauldron = game.Workspace.cauldron
local water = cauldron.Water
local value = cauldron.IngredientValue.Value
local user = game:GetService("Players").LocalPlayer
local mouse = user:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target == water then
local scroom = user.Backpack:FindFirstChild("Scroom")
if scroom then
value = value ..",Scroom"
scroom:Destroy()
end
end
end)
I’m not home right now but there should be a property for your tool and you can switch it on and off so it won’t detect the tool activation, maybe that helps?
One of the easier ways of doing this that most likely isn’t the best solution is by just detecting the players mouse.target.
(Btw im pretty sure that ur variable “value” is useless bc ur saving the value of the value object not the path to the actual object it self (the value variable is not a variable to the value object (that probably made no sense)))
Learn about on how to use the players mouse for your script. Once you did that u can detect what the player clicks on and then check the object name (Obviously there are many other ways to detect if its the desired object) to check if you should damage it or not.
Try this, its the only other solution I can think of.
local cauldron = game.Workspace.cauldron
local water = cauldron.Water
local value = cauldron.IngredientValue
local user = game:GetService("Players").LocalPlayer
local mouse = user:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Target == water then
local scroom = user.Backpack:FindFirstChild("Scroom")
if scroom then
value.Value = value.Value ..",Scroom"
scroom:Destroy()
end
end
end)