I made an on touch script so when the tool comes in contact with the object, it disappears. However, it disappears when you just simply walk into it. I'm new at scripting, so just learning!
for example, I pick up the tool and go to chop down a tree, but when I run into the object it disappears and I dont want it to disappear until the tool contacts the tree during the animation....
local tool = script.Parent
local scoop = tool.Scoop
local backpack = tool.Parent
local player = backpack.parent
local playerStats = player:FindFirstChild("leaderstats")
local playerItems = playerStats:FindFirstChild("Items")
local playerSpaces = playerStats:FindFirstChild("Spaces")
local function onTouch(partTouched)
local canHarvest = partTouched.Parent:FindFirstChild("canHarvest")
if canHarvest and script.Parent.Animations then
print("Found an Item") -- for testing purposes.
if canHarvest.Value == true and playerItems.Value < playerSpaces.Value then
playerItems.Value = playerItems.Value + 1
canHarvest.Value = false
partTouched.Transparency = 1
partTouched.CanCollide = false
wait(5)
canHarvest.Value = true
partTouched.Transparency = 0
partTouched.CanCollide = true
end
end
end
scoop.Touched:Connect(onTouch)

3 comments
wait(animation.Length) is what you need!
debounce
no both of you are wrong its AnimationTrack.Stopped