My roblox tool has a function to perform when activated but it literally does nothing
I tried to change it to tool.Deactivated, no change. I added print functions to my function to check if it was working, none of the prints worked, and theres no errors or anything.
If you want the code, here it is:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local tool = script.Parent
local leftPunch = animator:LoadAnimation(script:WaitForChild("RookieLeftPunch"))
local rightPunch = animator:LoadAnimation(script:WaitForChild("RookieRightPunch"))
local currentPunch = 0
local debounce = false
tool.Equipped:Connect(function()
print("equipped")
tool.Activated:Connect(function()
if debounce then return end
debounce = true
if currentPunch == 0 then
rightPunch:Play()
task.wait(0.4)
print("punched 1")
debounce = false
elseif currentPunch == 1 then
leftPunch:Play()
task.wait(0.4)
print("punched 2")
debounce = false
elseif currentPunch == 2 then
rightPunch:Play()
task.wait(0.8)
print("punched 3")
debounce = false
end
if currentPunch == 2 then
currentPunch = 0
else
currentPunch += 1
end
end)
end)
Usually, when there are no errors or print messages, it means a few things:
Here is the revised code, with comments, which may help you find the problem.