I was working on an axe and I wanted the script to check if the axe collides with anything while it’s activated, however, when I activate it the tip.Touched event still runs even if it is already done
am I doing something wrong?
local tool = script.Parent
local tip = tool.Part
local check = false
local players = game:GetService("Players")
tool.Activated:Connect(function()
local player = players:GetPlayerFromCharacter(tool.Parent)
tip.Touched:Connect(function(part)
print(part)
if part == "Tree" then
print(1)
else
print(2)
end
end)
end)
local tool = script.Parent
local tip = tool.Part
local check = false
local players = game:GetService("Players")
local canBeTouched = true --// This is the debounce.
tool.Activated:Connect(function()
local player = players:GetPlayerFromCharacter(tool.Parent)
tip.Touched:Connect(function(part)
if (canBeTouched) then
canBeTouched = false
print(part)
if part == "Tree" then
print(1)
else
print(2)
end
wait(2) --// The Time Per Hit.
canBeTouched = true
end
end)
end)