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

How can I add second animation to sword?

Asked by 6 years ago
Edited 6 years ago

Guys, I have tried creating sword using EppoBot script. It succeed, but the only thing I have unfinished is other attacks. In other words, in his video his sword has only ONE attack animation, while official ROBLOX sword has lunge, attack_1, attack_2, etc. If anybody can help, PLEASE help me adding second animation because I've searched likely every page of internet, but not even close to thing I've wanted. There is also another thing I would like to do. It's adding idle animation to this script (You can help as you wish). It would be best if you would give me answer. Thank you!

Here is 1st script:

local CanAttack = true

script.Parent.Activated:connect(function()

local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
if CanAttack == true then

attack:Play()

CanAttack = false

wait(1)

attack:Stop()

CanAttack = true

script.Parent.CanDamage.Value = true

end

end)

Here is 2nd script (incase you need it):

script.Parent.blade.Touched:connect(function(p)

if script.Parent.CanDamage.Value == true then

    script.Parent.CanDamage.Value = true

    p.Parent.Humanoid:TakeDamage(5)

end

end)

0
Misred but do you want us to make it randomize the animation so it randomly plays animation 1 or 2? DanielDeJong3 158 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local animations = {"1","2"} -- put ur animation ids here
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)

Make sure to change 1 and 2 with ur own animation id's. This script takes a random animation from ur animations list and plays it if the sword is used. Also I changed the can damage thingy because now if you swing u can damage if your sword is idle (not attacking) it doesn't do damage

EDIT: I have made it into a tool. did not add the damage script though. take it here: https://www.roblox.com/catalog/01463426021/redirect

0
Thank you! The script worked and I enjoy my sword more. As I can see, you are great at scripting. Good luck in future! dragopatiot 2 — 6y
0
Please accept the answer then as it gives you and me rep an people can see it's answered. DanielDeJong3 158 — 6y
0
Also, if you doing with hurting anyone here is the script. local animations = {"1438749801"} -- put ur animation ids here script.Parent.Activated:connect(function() 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(anima dog6779 25 — 6y
Ad

Answer this question