So i am trying to make like a tool that destroys parts when clicked an amount of times and i have a part named MinePart but i have like 50 of them with the same name the same intvalue because its like a mining game but it only shows up for 1 of the parts and not any others i really need help i have no idea what to do heres my script:
local Tool1 = script.Parent local Tool1Damage = script.Parent.Folder.Tool1Damage Tool1Damage.Value = 1
local MinePart = game.Workspace:FindFirstChild("MinePart") local Health = MinePart.Folder:FindFirstChild("Health") Health.Value = 15
Tool1.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target and mouse.Hit then if mouse.Target == MinePart then Health.Value = Health.Value - Tool1Damage.Value if Health.Value <= 0 then MinePart:Destroy() end end end end) end)
you would want to make a identifier if the block is a block or just part of the map after that just check if the part has the identifier
local Tool1 = script.Parent local Tool1Damage = script.Parent.Folder.Tool1Damage Tool1Damage.Value = 1 local MinePart = game.Workspace:FindFirstChild("MinePart") local Health = MinePart.Folder:FindFirstChild("Health") Health.Value = 15 Tool1.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target and mouse.Hit then if mouse.Target:FindFirstChild("Identifer") then --if it can find the identifer then set the part to Mouse.Target local Part = Mouse.Target Health.Value = Health.Value - Tool1Damage.Value if Health.Value <= 0 then Part:Destroy() end end end end) end)