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

How do i make a tool that can play two animations?

Asked by 5 years ago

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

01Remotes: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
View all 74 lines...

heres the click script ignore the other ones it should be named ****Attack

01local UserInputService = game:GetService("UserInputService")
02 
03 
04local tool = script.Parent
05local SwordAnimation = tool:WaitForChild("SwordAnimation")
06local Remotes = tool.Remotes
07local CantAttack = tool:WaitForChild("CanAttack")
08local SwordOut = tool:WaitForChild("SwordOut")
09 
10 
11local Attack = false
12local Attack_1 = false
13local Attack_2 = false
14local Attack_3 = false
15local Attack_4 = false
View all 57 lines...

1 answer

Log in to vote
0
Answered by 5 years ago

If you'd like to make something alternate between two options, you could use a boolean value. It could look something like this:

01local FirstAnimation = true
02 
03function PlayAnimation()
04    if FirstAnimation then
05        FirstAnimationTrack:Play()
06    else
07        SecondAnimationTrack:Play()
08    end
09    FirstAnimation = not FirstAnimation
10end

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.

Ad

Answer this question