-
Notifications
You must be signed in to change notification settings - Fork 0
/
sword creator
213 lines (183 loc) · 5.66 KB
/
sword creator
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
function createSword(ignorecharlist)
local ret = nil
task.spawn(function()
pcall(function()
local tool = Instance.new("Tool")
tool.Name = "LinkedSword"
tool.TextureId = "http://www.roblox.com/asset/?id=124987047"
tool.Grip = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
ret = tool
local handle = Instance.new("Part",tool)
handle.Name = "Handle"
handle.Reflectance = .4
handle.Size = Vector3.new(1,.8,4)
local function cS(p,n,id,vol)
local sound = Instance.new("Sound",p)
sound.Name = n
sound.SoundId = id
sound.Volume = vol
end
cS(handle,"Lunge","http://www.roblox.com/asset/?id=12222208",.6)
cS(handle,"Slash","http://www.roblox.com/asset/?id=12222216",.7)
cS(handle,"Unsheath","http://www.roblox.com/asset/?id=12222225",1)
local mesh = Instance.new("SpecialMesh",handle)
mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
mesh.TextureId = "http://www.roblox.com/asset/?id=12224218"
mesh.Scale = Vector3.one
do
local script = {Parent = tool}
--Rescripted by Luckymaxer
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Mesh = Handle:WaitForChild("Mesh")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")
local BaseUrl = "http://www.roblox.com/asset/?id="
local Grips = {
Up = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0),
Out = CFrame.new(0, 0, -1.5, 0, -1, -0, -1, 0, -0, 0, 0, -1),
}
local DamageValues = {
BaseDamage = 5,
SlashDamage = 10,
LungeDamage = 30,
}
local Damage = DamageValues.BaseDamage
local Sounds = {
Slash = Handle:WaitForChild("Slash"),
Lunge = Handle:WaitForChild("Lunge"),
Unsheath = Handle:WaitForChild("Unsheath"),
}
local LastAttack = 0
local ToolEquipped = false
local Character
local Player
local Humanoid
local RootPart
Tool.Enabled = true
local function CheckIfAlive()
return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and RootPart and RootPart.Parent) and true) or false)
end
local function SwordUp()
Tool.Grip = Grips.Up
end
local function SwordOut()
Tool.Grip = Grips.Out
end
local function IsTeamMate(Player1, Player2)
return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end
local function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
local function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
v:Destroy()
end
end
end
local function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
end
local function Lunge()
Damage = DamageValues.LungeDamage
Sounds.Lunge:Play()
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
local Force = Instance.new("BodyVelocity")
Force.velocity = Vector3.new(0, 10, 0)
Force.maxForce = Vector3.new(0, 4000, 0)
Debris:AddItem(Force, 0.5)
Force.Parent = RootPart
wait(0.25)
SwordOut()
wait(0.25)
if Force and Force.Parent then
Force:Destroy()
end
wait(0.5)
SwordUp()
end
local function Blow(Hit)
for _,v in pairs(ignorecharlist or {}) do
if Hit:IsDescendantOf(v) then
return
end
end
if not Hit or not Hit.Parent or not CheckIfAlive() then
return
end
local RightArm = (Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand"))
if not RightArm then
return
end
local RightGrip = RightArm:FindFirstChild("RightGrip")
if not RightGrip or (RightGrip.Part0 ~= RightArm and RightGrip.Part1 ~= RightArm) or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
return
end
local character = Hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player or IsTeamMate(Player, player)) then
return
end
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
humanoid:TakeDamage(Damage)
end
local function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack) < 0.2 then
Lunge()
else
Attack()
end
Damage = DamageValues.BaseDamage
LastAttack = Tick
Tool.Enabled = true
end
local function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChild("Humanoid")
RootPart = Character:FindFirstChild("HumanoidRootPart")
if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end
local function Unequipped()
ToolEquipped = false
end
SwordUp()
Handle.Touched:connect(Blow)
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
end
end)
end)
return ret
end
return createSword