Still have questions? Join our Discord server and get real time help.
0

# How to change connect so instead of touching an object, you have to left click then touch? [closed]

axelvl = 1 --Damage to ore.
allyWood = 5 --Money from ore.
resettime = .5 --Wait time for reuse.

Tool = script.Parent
ting = 0 --Debounce.

function hit()
print("hitting")
end

function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
wait(1)
Tool.Enabled = true
end

function onTouched(hitt)
if ting == 0 then
ting = 1
if hitt.Parent.Name == "Ore" then
user = game.Players:findFirstChild(Tool.Parent.Name)
hitt.Parent.hit.Value = hitt.Parent.hit.Value - axelvl
script.Parent.Handle.SwingThree:Play()
if hitt.Parent.hit.Value < 1 and hitt.Parent.Timber.Value == 0 then
hitt.Parent.Timber.Value = 1
script.Parent.Handle.EndSwing:Play()
wait(resettime)
else
wait(1)
end
end
ting = 0
end
end

Tool.Activated:connect(onActivated)

0
If you wish, you can fire a remoteevent that the tool interprets, and checks if the player is left clicking or not. Fifkee 693 — 7d

### Closed as Not Constructive by hiimgoodpack, Prestory, and alphawolvess

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

0
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer -- from a LocalScript
local mouse = Player:GetMouse()
axelvl = 1 --Damage to ore.
allyWood = 5 --Money from ore.
resettime = .5 --Wait time for reuse.

Tool = script.Parent
ting = 0 --Debounce.

function hit()
print("hitting")
end

function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
wait(1)
Tool.Enabled = true
end

function onTouched(hitt)
if ting == 0 then
ting = 1
if mouse.Target.Parent.Name == "Ore" then
user = game.Players:findFirstChild(Tool.Parent.Name)
hitt.Parent.hit.Value = hitt.Parent.hit.Value - axelvl
script.Parent.Handle.SwingThree:Play()
if hitt.Parent.hit.Value < 1 and hitt.Parent.Timber.Value == 0 then
hitt.Parent.Timber.Value = 1
script.Parent.Handle.EndSwing:Play()
wait(resettime)
else
wait(1)
end
end
ting = 0
end
end

Tool.Activated:connect(onActivated)
connection = mouse.Button1Down:connect(onTouched)


I edited the script so that you could use the player mouse to left-click on the object. I will work on an alternate option using ClickDetectors if this doesn't work for you. If it does, great!