#having trouble correcting a coding mistake with animations

1 messages · Page 1 of 1 (latest)

opal mural
#

i made a script for combat using 4 m1s, but i cant get the 4th animation to play, not only that but once the 3rd m1 registers it loops and wont cycle back to the first, if someone can help me, would i be able to paste my code for them to potentially find an issue?

compact ospreyBOT
#

studio** You are now Level 2! **studio

onyx dome
#

u got the animation priority correct?

opal mural
#

i think so

#

i might just send the code its probably easier that way

#

local UIS = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local M1 = humanoid:LoadAnimation(script.Animations.M1)
local M2 = humanoid:LoadAnimation(script.Animations.M2)
local M3 = humanoid:LoadAnimation(script.Animations.M3)
local M4 = humanoid:LoadAnimation(script.Animations.M4)
local combo = 1
UIS.InputEnded:Connect(function(I,E)
if E then return end
if I.UserInputType == Enum.UserInputType.MouseButton1 then
if combo == 4 then
game.ReplicatedStorage.MainEvent:FireServer()
M4: Play()
spawn(function()
task.wait(.1)
combo = 1

         end)
        
    
        
    elseif combo == 3 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M3: Play()
    elseif combo == 2 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M2: Play()
        combo = combo + 1
    elseif combo == 1 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M1: Play()
        combo = combo + 1
    end
    
end

end)

#

these are the names of my anims

#

wait i think i just noticed the problem

#

hang on

#

nevermind

onyx dome
#

u got it?

opal mural
#

no

#

it stood out more without the highlights

onyx dome
#

wait only some of your animations works?

opal mural
#

yeah only the first 3 m1s

#

i cant get the 4th one to work

onyx dome
#

can I see the properties of m4?

opal mural
#

the animation itself?

onyx dome
#

yeah in the animations folder

opal mural
#

yeah sure

onyx dome
#

is animation priority action?

opal mural
#

i made it on moonanimator

#

im not sure if i can check that box on that plugin

onyx dome
#

you can do it with script

opal mural
#

oh really

onyx dome
#

like
animation.AnimationPriority

#

and then Enum.AnimationPriority.Action

opal mural
#

im very new to scripting so i might ask some dumb questions

#

would i have to add a script for the animation or put this in an already existing script

onyx dome
#

just use the script you already have

opal mural
#

okay

onyx dome
opal mural
#

oh okay

#

im guessing i put this under the m4 animation?

onyx dome
#

yeah

M4.Priority = Enum.AnimationPriority.Action4

#

just put this line under "local M4 = humanoid:LoadAnimation(script.Animations.M4)"

opal mural
#

okay, ill try it now and playtest thanks dude

opal mural
#

if it doesnt work ill reupload my animation since i think itll be an issue with the ID

onyx dome
#

yeah, it might not be published correctly

opal mural
#

i put it under the line you said

onyx dome
#

can you send the script?

opal mural
#

sure

#

local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local M1 = humanoid:LoadAnimation(script.Animations.M1)
local M2 = humanoid:LoadAnimation(script.Animations.M2)
local M3 = humanoid:LoadAnimation(script.Animations.M3)
local M4 = humanoid:LoadAnimation(script.Animations.M4)
Enum.AnimationPriority.M4
local combo = 1
UIS.InputEnded:Connect(function(I,E)
if E then return end
if I.UserInputType == Enum.UserInputType.MouseButton1 then
if combo == 4 then
game.ReplicatedStorage.MainEvent:FireServer()
M4: Play()
spawn(function()
task.wait(.1)
combo = 1

         end)
        
    
        
    elseif combo == 3 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M3: Play()
    elseif combo == 2 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M2: Play()
        combo = combo + 1
    elseif combo == 1 then
        game.ReplicatedStorage.MainEvent:FireServer()
        M1: Play()
        combo = combo + 1
    end
    
end

end)

#

was i supposed to add more than just that one line

onyx dome
opal mural
#

oh

compact ospreyBOT
#

studio** You are now Level 3! **studio

onyx dome
#

do M4.Priority = Enum.AnimationPriority.Action4

opal mural
#

yeah okay no error now, but its still the same issue#

#

keeps repeating the third m1 with no cycle back to the first

onyx dome
#

like its looped?

#

and you dont want it looped

opal mural
#

yeah it loops the third m1

opal mural
onyx dome
opal mural
#

M3

onyx dome
#

well the combo dosent change if it is 3

#

so its just gonna be stuck on 3

#
UIS.InputEnded:Connect(function(I,E)
    if E then return end
    if I.UserInputType == Enum.UserInputType.MouseButton1 then
        if combo == 4 then
            game.ReplicatedStorage.MainEvent:FireServer()
            M4: Play()
            spawn(function()
                task.wait(.1)
                combo = 1

             end)



        elseif combo == 3 then
            game.ReplicatedStorage.MainEvent:FireServer()
            M3: Play()
            combo += 1
        elseif combo == 2 then
            game.ReplicatedStorage.MainEvent:FireServer()
            M2: Play()
            combo += 1
        elseif combo == 1 then
            game.ReplicatedStorage.MainEvent:FireServer()
            M1: Play()
            combo += 1
        end

    end

end)

I changed "combo = combo + 1" to "combo += 1" cuz its shorter and cleaner

opal mural
#

i appreciate ur help really

#

im gonna paste this in now ill see what happens

#

oh my god bro

#

you're actually my goat

#

it works perfectly now

onyx dome
#

nice

opal mural
#

thanks so much bro