-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTOOLScript Sword
39 lines (29 loc) · 925 Bytes
/
TOOLScript Sword
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- TOOL - Build a sword with Animations and Random Damage
--> Tool -> Add Parts, BoolValue "CanDamage" and 2 Animations called "Idle" & "Attack"
--> Tool -> LocalScript
local CanAttack = true
local idle = script.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Humanoid:LoadAnimation(script.Attack)
script.Parent.Equipped:connect(function()
idle:Play()
end)
script.Parent.Activated:connect(function()
if CanAttack == true then
attack:Play()
idle:Stop()
CanAttak = false
wait(1)
attack:Stop()
idle:Play()
CanAttack = true
script.Parent.CanDamage.Value = true
end
end)
--> Tool -> SwordScript
script.Parent.blade.Touched:connect(function(player)
if script.Parent.CanDamage.Value == true then
local blowdamage = math.Random(5,20) -- makes a damage between 5 and 20 Points
script.Parent.CanDamage.Value = false
player.Parent.Humanoid:TakeDamage(blowdamage)
end
end)