Hello. I'm trying to make 2 objects that are both the same, and when you click on one of the objects that object that you clicked is destroyed and then respawned, But when I click on the other object the first one still gets destroyed, I'm using a custom click detector, and I'm wondering how you would be able to tell what object the player is clicking, Does anyone know what to do?
Here is the code for the custom click detector:
local Tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local hits = 0
local max_hits = 5
local player = game.Players.LocalPlayer
Tool.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if mouse.Target:FindFirstChild("Clickable") then
print("You did it") --Testing
hits = hits + 1
if hits >= max_hits then
if hits >= max_hits then
player.leaderstats.Wood.Value = player.leaderstats.Wood.Value + 1
wait(3)
hits = 0
end
end
end
end)
end)
