Hello! So I have this script to where when I click a certain part, that part that I click will be destroyed, and I will have the tool in my inventory. What I am needing is from it to be changed from being a click detector script, to an on touched script. Where instead of it being clicked, all I need is for it to be touched. I want the same stuff to happen, just changing on how to obtain the tool. Here is the script:
script.Parent.ClickDetector.MouseClick:connect(function(plr)
if plr.Backpack:FindFirstChild("Brick") then
else
local clone = game.Lighting.Brick:Clone()
clone.Parent = plr.Backpack
script.Parent:Destroy()
end
end)

6 comments
What does the --TODO: DO SOMETHING HERE mean?
sorry shouldve clarified. you have an if statement that when the condition is true, it doesn't do anything. if you want to do something when the script finds a Brick in the backpack, write it on the line that says TODO: did you manage to get the script work alright?
^^ Use :GetService for Lighting
I believe that it will still throw an error if im not wrong.
Yes, this will throw an error. 'plr' does not refer to a player, it refers to the part that touched the part firing the event. Use GetPlayerFromCharacter(part.Parent) to acquire the player (if it exists).
didn't catch that. i'll make sure to update