Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My animation code is not working and there are no errors, how can I fix this?

Asked by 4 years ago
--Services
local Players = game:GetService("Players")

--Modules
--Constants
local Character = script.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Player = Players:GetPlayerFromCharacter(Character)

--Variables
local CurrentTool
local CurrentFunc

--Functions
--Main
Character.ChildAdded:Connect(function(o)
    if o:IsA("Tool") then
        CurrentTool = o
        if CurrentFunc then CurrentFunc:Disconnect() end 
        local Animations = o:FindFirstChild("Animations")
        if Animations then
            local TestAnimation = Animations:FindFirstChild("Main")
            if not TestAnimation then return end  
            CurrentFunc = o.Activated:Connect(function()
                local Test = Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(TestAnimation)
                Test:Play()
            end)
        end
    end
end)

1 answer

Log in to vote
-1
Answered by 4 years ago

Make sure your "Tool" have a handle

If not then turn "requirehandle" property to false

Also if a script not giving any error, i suggest using the print function to see where the script manage to go through and where it didnt

Ad

Answer this question