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

Why do the animations not play, but the sound effects do? And how can I make them play?

Asked by 2 years ago
Edited 2 years ago

I've changed my code but it still doesn't work?

script.Parent.OnServerEvent:connect(function(Player, Action, V1)
    local c = Player.Character or Player.CharacterAdded:Wait()
    if Action == "Release" then 
        ButtonDown = false
    end
    if Enabled == false  then return end
    if Action == "Combat" then 
        Enabled = false
        local Humanoid = c:WaitForChild("Humanoid")
        local Animator = Humanoid:WaitForChild("Animator")
        if Combo == 1 then
                Combo = 2
                local Track = Instance.new("Animation")
                Track.AnimationId = "rbxassetid://11285688290"
                local Anim = Animator:LoadAnimation(Track)
                Anim:Play()
                wait(0.5)
Enabled = true
ButtonDown = false
Combo = 1

script.Parent.OnServerEvent:connect(function(Player, Action, V1)
    local c = Player.Character or Player.CharacterAdded:Wait()
    if Action == "Release" then 
        ButtonDown = false
    end
    if Enabled == false  then return end
    if Action == "Combat" then 
        Enabled = false
        if Combo == 1 then
                Combo = 2
                local Track = Instance.new("Animation")
                Track.AnimationId = "rbxassetid://11285688290"
                local Anim = c.Humanoid:LoadAnimation(Track)
                Anim:Play()
                wait(0.5)
            elseif Combo == 2 then
                Combo = 3
                local Track = Instance.new("Animation")
                Track.AnimationId = "rbxassetid://11285688290"
                local Anim = c.Humanoid:LoadAnimation(Track)
                Anim:Play()
                wait(0.5)
            elseif Combo == 3 then
                Combo = 1
                local Track = Instance.new("Animation")
                Track.AnimationId = "rbxassetid://11285688290"
                local Anim = c.Humanoid:LoadAnimation(Track)
                Anim:Play()
                wait(0.5)
            end
            end
            wait(0.09)
            local Region = Region3.new(V1-Vector3.new(3,3,3),V1+Vector3.new(3,3,3))
            local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
            for i,v in pairs(RTable) do
                if v.Parent:findFirstChild("Humanoid") and v.Parent:findFirstChild("Deb") == nil and v.Parent ~= c then
                    local Deb = Instance.new("BoolValue", v.Parent)
                    Deb.Name = "Deb"
                    game.Debris:AddItem(Deb,0,2)
                    v.Parent.Humanoid:TakeDamage(5)
                    local S = Instance.new("Sound", v)
                    S.SoundId = "rbxassetid://11285764868"
                    S.PlaybackSpeed = math.random(80,120)/100
                    S:Play()
                end
        Enabled = true
    end 
end)

3 answers

Log in to vote
0
Answered by 2 years ago

Humanoid:LoadAnimation does not work anymore. Use a "Animator" Instead

0
How would I put that in? doomaker3003 0 — 2y
0
nvm figured it out doomaker3003 0 — 2y
0
I edited post to show my new code, still doesn't work? doomaker3003 0 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

What prints in the console?

Maybe try giving a parent to the animation?

Edit: Ok so are you sure the "Play()" line is being ran through? you can do "print("Playing") right above the "Play()" line to see if it is, if "Playing" doesn't print that means the Action isn't working properly.

Otherwise I'm not sure what could be the issue, as in my case, I make the animations before, and I place them in a folder inside a tool, so i can use them, here is an example of my code for a knife weapon:

function ActionManager()
    if playingIdle == true then
        if Attacking == false then
            Attacking = true

            --- Combo String
            if ComboNum == 0 then
                ComboNum = 1
                Slash1()
            elseif ComboNum == 1 then
                ComboNum = 0
                Slash2()
            end


            wait(0.2)
            Attacking = false
        end

    end
end

knife.Activated:Connect(ActionManager)

local Anim_Slash1 = knife.Handle.Animations.Slash1
local Slash1Anim = holderChar.Humanoid:LoadAnimation(Anim_Slash1)

function Slash1()
    Slash1Anim:Play()

    wait(0.16)

    local SlashSounds = SoundsFolder.SlashSounds:GetChildren()
    local randomSlash = SlashSounds[math.random(1, #SlashSounds)]
    randomSlash:Play()
end

Maybe you can try making the animations beforehand like i did with my code? If that doesn't work I have no idea what could be the issue

0
nothing prints in the console when it happens, the anim just doesn't play. And how would I give a parent to the anim? I'm relatively new to Lua doomaker3003 0 — 2y
0
You can do "Track.Parent = game.ReplicatedStorage" , ofc you can place it wherever you want it to be, also why is there 2 same functions for 1 RemoteEvent SharkRayMaster 265 — 2y
0
aight ill give that a try, i think there's just one function but its being displayed funny because of how i typed up the post doomaker3003 0 — 2y
0
nope, doesn't help doomaker3003 0 — 2y
0
Well, I'm not sure then, let me edit my answer to add some code maybe? SharkRayMaster 265 — 2y
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Hello! I am currently working on a solution (which I'm sure I almost have figured out) and will be updated ASAP.

Answer this question