this is my script in tool. it works if i click it will 1x hit ore. i want if i hold it will repeat mining function but if i only click it will activates only 1x.
local tool = script.Parent local swing = true tool.Handle.Touched:Connect(function(otherPart) if otherPart.Name == 'Rock' then wait() tool.Mining.Value = false end end) local function mine() if script.Parent.Damage.Value == 13 then -- this is only double dmg if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[script.Parent.Parent.Name].UserId, 17837947) then script.Parent.Damage.Value = 26 end end if swing then swing = false tool.Mining.Value = true local str = Instance.new("StringValue") str.Name = "toolanim" str.Value = "Slash" str.Parent = tool wait(0.35) swing = true tool.Mining.Value = false else return end end tool.Activated:Connect(mine)
Hello, I hope this will help:
local tool = script.Parent local swing = true equipped = false -- set value which will track if tool is equipped tool.Equipped:Connect(function() -- set equipped value to true equipped = true end) tool.Unequipped:Connect(function() -- set it to false equipped = false end) tool.Handle.Touched:Connect(function(otherPart) if otherPart.Name == 'Rock' then wait() tool.Mining.Value = false end end) local function mine() if script.Parent.Damage.Value == 13 then -- this is only double dmg if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[script.Parent.Parent.Name].UserId, 17837947) then script.Parent.Damage.Value = 26 end end if swing then swing = false tool.Mining.Value = true local str = Instance.new("StringValue") str.Name = "toolanim" str.Value = "Slash" str.Parent = tool wait(0.35) swing = true tool.Mining.Value = false else return end end local player = game:GetService("Players").LocalPlayer -- define localplayer or player if server script mouse = player:GetMouse() -- get player's mouse mouse.Button1Down:Connect(function() -- if holding left mouse button function if equipped == true then -- if tool is equipped call mine function mine() end end) tool.Activated:Connect(mine)