View difference between Paste ID: MaRUakNh and fXDZrQZz
SHOW: | | - or go back to the newest paste.
1
Tool0 = Instance.new("Tool")
2
Part1 = Instance.new("Part")
3
SpecialMesh2 = Instance.new("SpecialMesh")
4
Tool0.Name = "Linked Sword"
5
Tool0.ToolTip = "It slices, it dices. One click to slash, double click to lunge. Lunging does 3x damage."
6
Tool0.Parent = owner.Backpack
7
Tool0.Grip = CFrame.new(0, 0, -1.5) * CFrame.Angles(math.rad(90),math.rad(90),0)
8
Tool0.TextureId = 'rbxasset://Textures/Sword128.png'
9
Part1.Name = "Handle"
10
Part1.Parent = Tool0
11
Part1.Color = Color3.fromRGB(99, 95, 98)
12
Part1.Reflectance = 0.4
13
Part1.Size = Vector3.new(1, 0.8, 4)
14-
SpecialMesh2.Parent = Part1
14+
local mesh = Instance.new("SpecialMesh" , real)
15-
SpecialMesh2.MeshId = "rbxasset://fonts/sword.mesh"
15+
mesh.MeshId = 'rbxassetid://1036532801'
16-
SpecialMesh2.Scale = Vector3.new(1,1,1)
16+
mesh.TextureId = 'rbxassetid://1036532816'
17-
SpecialMesh2.TextureId = "rbxasset://textures/SwordTexture.png"
17+
mesh.Scale = Vector3.new(.15,.15,.15)
18-
SpecialMesh2.MeshType = Enum.MeshType.FileMesh
18+
19
Handle = Part1
20
21
function Create(ty)
22
	return function(data)
23
		local obj = Instance.new(ty)
24
		for k, v in pairs(data) do
25
			if type(k) == 'number' then
26
				v.Parent = obj
27
			else
28
				obj[k] = v
29
			end
30
		end
31
		return obj
32
	end
33
end
34
35
local BaseUrl = "rbxassetid://"
36
37
Players = game:GetService("Players")
38
Debris = game:GetService("Debris")
39
RunService = game:GetService("RunService")
40
41
DamageValues = {
42
	BaseDamage = 5,
43
	SlashDamage = 10,
44
	LungeDamage = 30
45
}
46
47
--For R15 avatars
48
Animations = {
49
	R15Slash = 522635514,
50
	R15Lunge = 522638767
51
}
52
53
Damage = DamageValues.BaseDamage
54
55
Grips = {
56
	Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
57
	Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
58
}
59
Slash = Instance.new("Sound" , owner.Character.Head)
60
Slash.SoundId = 'rbxassetid://12222216'
61
Slash.Name = 'SwordSlash'
62
Lunge = Instance.new("Sound" , owner.Character.Head)
63
Lunge.SoundId = 'rbxassetid://12222208'
64
Lunge.Name = 'SwordLunge'
65
Unsheath = Instance.new("Sound" , owner.Character.Head)
66
Unsheath.SoundId = 'rbxassetid://12222225'
67
Unsheath.Name = 'Unsheath'
68
Sounds = {
69
 Slash = owner.Character.Head:WaitForChild("SwordSlash"),
70
 Lunge = owner.Character.Head:WaitForChild("SwordLunge"),
71
 Unsheath = owner.Character.Head:WaitForChild("Unsheath")
72
}
73
74
ToolEquipped = false
75
76
--For Omega Rainbow Katana thumbnail to display a lot of particles.
77
for i, v in pairs(Handle:GetChildren()) do
78
	if v:IsA("ParticleEmitter") then
79
		v.Rate = 20
80
	end
81
end
82
83
Tool.Grip = Grips.Up
84
Tool.Enabled = true
85
86
function IsTeamMate(Player1, Player2)
87
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
88
end
89
90
function TagHumanoid(humanoid, player)
91
	local Creator_Tag = Instance.new("ObjectValue")
92
	Creator_Tag.Name = "creator"
93
	Creator_Tag.Value = player
94
	Debris:AddItem(Creator_Tag, 2)
95
	Creator_Tag.Parent = humanoid
96
end
97
98
function UntagHumanoid(humanoid)
99
	for i, v in pairs(humanoid:GetChildren()) do
100
		if v:IsA("ObjectValue") and v.Name == "creator" then
101
			v:Destroy()
102
		end
103
	end
104
end
105
106
function Blow(Hit)
107
	if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
108
		return
109
	end
110
	local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
111
	if not RightArm then
112
		return
113
	end
114
	local RightGrip = RightArm:FindFirstChild("RightGrip")
115
	if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
116
		return
117
	end
118
	local character = Hit.Parent
119
	if character == Character then
120
		return
121
	end
122
	local humanoid = character:FindFirstChildOfClass("Humanoid")
123
	if not humanoid or humanoid.Health == 0 then
124
		return
125
	end
126
	local player = Players:GetPlayerFromCharacter(character)
127
	if player and (player == Player or IsTeamMate(Player, player)) then
128
		return
129
	end
130
	UntagHumanoid(humanoid)
131
	TagHumanoid(humanoid, Player)
132
	humanoid:TakeDamage(Damage)	
133
end
134
135
136
function Attack()
137
	Damage = DamageValues.SlashDamage
138
	Sounds.Slash:Play()
139
140
	if Humanoid then
141
		if Humanoid.RigType == Enum.HumanoidRigType.R6 then
142
			local Anim = Instance.new("StringValue")
143
			Anim.Name = "toolanim"
144
			Anim.Value = "Slash"
145
			Anim.Parent = Tool
146
		elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
147
			local Anim = Tool:FindFirstChild("R15Slash")
148
			if Anim then
149
				local Track = Humanoid:LoadAnimation(Anim)
150
				Track:Play(0)
151
			end
152
		end
153
	end	
154
end
155
156
function Lunge()
157
	Damage = DamageValues.LungeDamage
158
159
	Sounds.Lunge:Play()
160
	
161
	if Humanoid then
162
		if Humanoid.RigType == Enum.HumanoidRigType.R6 then
163
			local Anim = Instance.new("StringValue")
164
			Anim.Name = "toolanim"
165
			Anim.Value = "Lunge"
166
			Anim.Parent = Tool
167
		elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
168
			local Anim = Tool:FindFirstChild("R15Lunge")
169
			if Anim then
170
				local Track = Humanoid:LoadAnimation(Anim)
171
				Track:Play(0)
172
			end
173
		end
174
	end	
175
	if CheckIfAlive() then
176
		local Force = Instance.new("BodyVelocity")
177
		Force.velocity = Vector3.new(0, 10, 0) 
178
		Force.maxForce = Vector3.new(0, 4000, 0)
179
		Debris:AddItem(Force, 0.4)
180
		Force.Parent = Torso
181
	end
182
	
183
	wait(0.2)
184
	Tool.Grip = Grips.Out
185
	wait(0.6)
186
	Tool.Grip = Grips.Up
187
188
	Damage = DamageValues.SlashDamage
189
end
190
191
Tool.Enabled = true
192
LastAttack = 0
193
194
function Activated()
195
	if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
196
		return
197
	end
198
	Tool.Enabled = false
199
	local Tick = RunService.Stepped:wait()
200
	if (Tick - LastAttack < 0.2) then
201
		Lunge()
202
	else
203
		Attack()
204
	end
205
	LastAttack = Tick
206
	--wait(0.5)
207
	Damage = DamageValues.BaseDamage
208
	local SlashAnim = (Tool:FindFirstChild("R15Slash") or Create("Animation"){
209
		Name = "R15Slash",
210
		AnimationId = BaseUrl .. Animations.R15Slash,
211
		Parent = Tool
212
	})
213
	
214
	local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
215
		Name = "R15Lunge",
216
		AnimationId = BaseUrl .. Animations.R15Lunge,
217
		Parent = Tool
218
	})
219
	Tool.Enabled = true
220
end
221
222
function CheckIfAlive()
223
	return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
224
end
225
226
function Equipped()
227
	Character = Tool.Parent
228
	Player = Players:GetPlayerFromCharacter(Character)
229
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
230
	Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
231
	if not CheckIfAlive() then
232
		return
233
	end
234
	ToolEquipped = true
235
	Sounds.Unsheath:Play()
236
end
237
238
function Unequipped()
239
	Tool.Grip = Grips.Up
240
	ToolEquipped = false
241
end
242
243
Tool.Activated:Connect(Activated)
244
Tool.Equipped:Connect(Equipped)
245
Tool.Unequipped:Connect(Unequipped)
246
247
Connection = Handle.Touched:Connect(Blow)
248
local ls = [[
249
250
Mouse_Icon = "rbxasset://textures/GunCursor.png"
251
Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
252
253
Tool = game:GetService("Players").LocalPlayer.Backpack['Linked Sword'] or game:GetService("Players").LocalPlayer.Character['Linked Sword']
254
255
Mouse = nil
256
257
function UpdateIcon()
258
	if Mouse then
259
		Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
260
	end
261
end
262
263
function OnEquipped(ToolMouse)
264
	Mouse = ToolMouse
265
	UpdateIcon()
266
end
267
268
function OnChanged(Property)
269
	if Property == "Enabled" then
270
		UpdateIcon()
271
	end
272
end
273
274
Tool.Equipped:Connect(OnEquipped)
275
Tool.Changed:Connect(OnChanged)
276
]]
277
NLS(ls, owner.Character)