The easiest questions to ask are the ones that seem like asking. I couldn't find any other scripts that held similar traits to the one I'm trying to script, and a search doesn't do me any better when I don't know the terms I'm trying to word.
The current script you'll see in the block allows the player to barely touch the ore and deal damage to it without having to left click. This is problematic if I want players to left click first.
Is there a function where a player will press mousebutton1 down and it'll put a timer waiting for the player to touch the ore?
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
user.leaderstats.Frang.Value = user.leaderstats.Frang.Value + allyWood
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 = Tool.Blade.Touched:connect(onTouched)
