so im making a game and i want it that when i click the first animation will play and when i click again the second one will play then if i click again it will play the first one again, you get it
tool/animation script
01 | Remotes:WaitForChild( "SwordSlash" ).OnServerInvoke = function (player,tool,SAnimation) |
02 |
03 | local char = player.Character |
04 | local Hm = char:WaitForChild( "Humanoid" ) |
05 | local rp = char:WaitForChild( "HumanoidRootPart" ) |
06 |
07 | local HitBox = tool:WaitForChild( "HitBox" ) |
08 |
09 | local CanAttack = tool:WaitForChild( "CanAttack" ) |
10 | local SwordOut = tool:WaitForChild( "SwordOut" ) |
11 | local CoolDown = 0.5 |
12 |
13 | local AttackName = "Katana Slash" --You can Rename this one |
14 | local AttackDamage = 10 |
15 | local Length = 1 --How long it will last |
heres the click script ignore the other ones it should be named ****Attack
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 |
03 |
04 | local tool = script.Parent |
05 | local SwordAnimation = tool:WaitForChild( "SwordAnimation" ) |
06 | local Remotes = tool.Remotes |
07 | local CantAttack = tool:WaitForChild( "CanAttack" ) |
08 | local SwordOut = tool:WaitForChild( "SwordOut" ) |
09 |
10 |
11 | local Attack = false |
12 | local Attack_ 1 = false |
13 | local Attack_ 2 = false |
14 | local Attack_ 3 = false |
15 | local Attack_ 4 = false |
If you'd like to make something alternate between two options, you could use a boolean value. It could look something like this:
01 | local FirstAnimation = true |
02 |
03 | function PlayAnimation() |
04 | if FirstAnimation then |
05 | FirstAnimationTrack:Play() |
06 | else |
07 | SecondAnimationTrack:Play() |
08 | end |
09 | FirstAnimation = not FirstAnimation |
10 | end |
If you implement something like this into where you play animations, every time you play an animation, it will switch, because FirstAnimation alternates between true and false.