I've been really confused with animations and sword scripts for quite a while. Recently I found this code:
local Damage = 10
local CanAttack = true
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Character = Tool.Parent
local RaycastHitbox = require(Tool.RaycastHitbox)
local Hitbox = RaycastHitbox:Initialize(Tool, {Character})
Hitbox:PartMode(true)
local animations = {"4980024148","4980017811"}
local CanAttack = true
script.Parent.Activated:connect(function()
if CanAttack == true then
script.Parent.CanDamage.Value = true
local animation = Instance.new("Animation", script.Parent.Parent)
animation.AnimationId = "http://www.roblox.com/asset?id="..animations[math.random(1, #animations)]
local chosenanim = script.Parent.Parent.Humanoid:LoadAnimation(animation)
chosenanim:Play()
CanAttack = false
wait(1)
CanAttack = true
script.Parent.CanDamage.Value = false
end
end)
This code works perfectly however how would I remove the random variable? So animation 1 and 2 just play in sequence rather than random occurrence?
Example On click it Plays Animation 1 Animation 2 Animation 1 Animation 2
Instead of
Animation 1 Animation 1 Animation 1 Animation 2 etc just random
