View difference between Paste ID: TLf6Veu4 and H8WLw3QJ
SHOW: | | - or go back to the newest paste.
1
--MADE BY OneLegend (NOT THE SCRIPT) Thanks to CyberFromLU for letting me Publish! REGULAR SCRIPT: Go to line 16 and put your name where it says "YOUR NAME HERE"
2
-------------------------------------------------------------------------------------
3
--[[
4
Can Bomb, an improvised explosive device made from ammonium nitrate, a bean can, and a fuse.
5
Produces a nice medium-pressure explosion.
6
http://www.roblox.com/asset/?id=10470609 Beans
7
http://www.roblox.com/asset/?id=45934917 Beans
8
--]]
9
10
11
if script == nil then return end
12
13
14
15
16-
Player = script:FindFirstChild("Player") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("mogoon")
16+
Player = script:FindFirstChild("beasrt") ~= nil and script.Player.Value or game:GetService("beasrt"):FindFirstChild("beasrt")
17
Name = "Can Bomb"
18
selected = false
19
Button1Down = false
20
thrown = false
21
22
23
function makeParts(format)
24
	local grenade = Instance.new("Model")
25
	grenade.Name = Name
26
	grenade.Parent = Player.Character
27
	local pm = Instance.new("Part")
28
	pm.Name = "Handle"
29
	pm.formFactor = "Symmetric"
30
	pm.Size = Vector3.new(1, 1, 1)
31
	pm.BrickColor = BrickColor.new("Black")
32
	pm.CanCollide = false
33
	pm.Locked = true
34
	pm.TopSurface = 0
35
	pm.BottomSurface = 0
36
	pm.Parent = grenade
37
	local m = Instance.new("SpecialMesh")
38
	m.MeshType = "FileMesh"
39
	m.Scale = Vector3.new(1, 1, 1)
40
	m.MeshId = "http://www.roblox.com/asset/?id=10470609"
41
	m.TextureId = "http://www.roblox.com/asset/?id=45934917"
42
	m.Parent = pm
43
	local w = Instance.new("Weld")
44
	w.Part0 = pm
45
	if format == "hand" then
46
		w.Part1 = Player.Character:FindFirstChild("Right Arm")
47
		w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
48
		w.C1 = CFrame.new()
49
	elseif format == "holster" then
50
		w.Part1 = Player.Character:FindFirstChild("Torso")
51
		w.C0 = CFrame.new(0.6, -0.4, 0.6)
52
		w.C1 = CFrame.new()
53
		grenade.Name = Name.. " (Holstered)"
54
	end
55
	w.Parent = pm
56
	local s = Instance.new("Sound")
57
	s.Name = "Explode"
58
	s.SoundId = "rbxasset://sounds\\collide.wav"
59
	s.Volume = 1
60
	s.Pitch = 1
61
	s.Looped = false
62
	s.Parent = pm
63
	local s = Instance.new("Sound")
64
	s.Name = "Pin"
65
	s.SoundId = "http://www.roblox.com/Asset/?id=31760113"
66
	s.Volume = 1
67
	s.Pitch = 1
68
	s.Looped = true
69
	s.Parent = pm
70
	local s = Instance.new("Sound")
71
	s.Name = "Light"
72
	s.SoundId = "http://www.roblox.com/Asset/?id=19095020"
73
	s.Volume = 1
74
	s.Pitch = 1
75
	s.Looped = false
76
	s.Parent = pm
77
	local p = Instance.new("Part")
78
	p.Name = "Rag"
79
	p.formFactor = "Symmetric"
80
	p.Size = Vector3.new(1, 1, 1)
81
	p.BrickColor = BrickColor.new("White")
82
	p.CanCollide = false
83
	p.Transparency = 1
84
	p.Locked = true
85
	p.TopSurface = 0
86
	p.BottomSurface = 0
87
	p.Parent = grenade
88
	local f = Instance.new("Fire")
89
	f.Enabled = false
90
	f.Name = "Fire"
91
	f.Color = Color3.new(1, 0.5, 0)
92
	f.SecondaryColor = Color3.new(1, 0.75, 0.5)
93
	f.Heat = 25
94
	f.Size = 2
95
	f.Parent = p
96
	local m = Instance.new("CylinderMesh")
97
	m.Scale = Vector3.new(0.15, 0.4, 0.15)
98
	m.Parent = p
99
	local w = Instance.new("Weld")
100
	w.Part0 = p
101
	w.Part1 = pm
102
	w.C0 = CFrame.new(0, -0.6, 0)
103
	w.C1 = CFrame.new()
104
	w.Parent = p
105
end
106
107
108
function removeParts(format)
109
	if format == "hand" then
110
		if Player.Character:FindFirstChild(Name) ~= nil then
111
			Player.Character[Name]:Remove()
112
		end
113
	elseif format == "holster" then
114
		if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
115
			Player.Character[Name.. " (Holstered)"]:Remove()
116
		end
117
	end
118
end
119
120
121
function SetAngle(Joint, Angle, Character)
122
	if Character == nil then return false end
123
	local Joints = {
124
		Character.Torso:FindFirstChild("Right Shoulder 2"),
125
		Character.Torso:FindFirstChild("Left Shoulder 2"),
126
		Character.Torso:FindFirstChild("Right Hip 2"),
127
		Character.Torso:FindFirstChild("Left Hip 2")
128
	}
129
	if Joints[Joint] == nil then return false end
130
	if Joint == 1 or Joint == 3 then
131
		Joints[Joint].DesiredAngle = Angle
132
	end
133
	if Joint == 2 or Joint == 4 then
134
		Joints[Joint].DesiredAngle = -Angle
135
	end
136
end
137
138
139
function ForceAngle(Joint, Angle, Character)
140
	if Character == nil then return false end
141
	local Joints = {
142
		Character.Torso:FindFirstChild("Right Shoulder 2"),
143
		Character.Torso:FindFirstChild("Left Shoulder 2"),
144
		Character.Torso:FindFirstChild("Right Hip 2"),
145
		Character.Torso:FindFirstChild("Left Hip 2")
146
	}
147
	if Joints[Joint] == nil then return false end
148
	if Joint == 1 or Joint == 3 then
149
		Joints[Joint].DesiredAngle = Angle
150
		Joints[Joint].CurrentAngle = Angle
151
	end
152
	if Joint == 2 or Joint == 4 then
153
		Joints[Joint].DesiredAngle = -Angle
154
		Joints[Joint].CurrentAngle = -Angle
155
	end
156
end
157
158
159
function SetSpeed(Joint, Speed, Character)
160
	if Character == nil then return false end
161
	local Joints = {
162
		Character.Torso:FindFirstChild("Right Shoulder 2"),
163
		Character.Torso:FindFirstChild("Left Shoulder 2"),
164
		Character.Torso:FindFirstChild("Right Hip 2"),
165
		Character.Torso:FindFirstChild("Left Hip 2")
166
	}
167
	if Joints[Joint] == nil then return false end
168
	Joints[Joint].MaxVelocity = Speed
169
end
170
171
172
function DisableLimb(Limb, Character)
173
	if Character == nil then return false end
174
	if Character:FindFirstChild("Torso") == nil then return false end
175
	local Joints = {
176
		Character.Torso:FindFirstChild("Right Shoulder"),
177
		Character.Torso:FindFirstChild("Left Shoulder"),
178
		Character.Torso:FindFirstChild("Right Hip"),
179
		Character.Torso:FindFirstChild("Left Hip")
180
	}
181
	local Limbs = {
182
		Character:FindFirstChild("Right Arm"),
183
		Character:FindFirstChild("Left Arm"),
184
		Character:FindFirstChild("Right Leg"),
185
		Character:FindFirstChild("Left Leg")
186
	}
187
	if Joints[Limb] == nil then return false end
188
	if Limbs[Limb] == nil then return false end
189
	local Joint = Instance.new("Motor")
190
	Joint.Parent = Character.Torso
191
	Joint.Part0 = Character.Torso
192
	Joint.Part1 = Limbs[Limb]
193
	if Limb == 1 then
194
		Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
195
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
196
		Joint.Name = "Right Shoulder 2"
197
	elseif Limb == 2 then
198
		Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
199
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
200
		Joint.Name = "Left Shoulder 2"
201
	elseif Limb == 3 then
202
		Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
203
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
204
		Joint.Name = "Right Hip 2"
205
	elseif Limb == 4 then
206
		Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
207
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
208
		Joint.Name = "Left Hip 2"
209
	end
210
	Joint.MaxVelocity = Joints[Limb].MaxVelocity
211
	Joint.CurrentAngle = Joints[Limb].CurrentAngle
212
	Joint.DesiredAngle = Joints[Limb].DesiredAngle
213
	Joints[Limb]:Remove()
214
end
215
216
217
function ResetLimbCFrame(Limb, Character)
218
	if Character == nil then return false end
219
	if Character.Parent == nil then return false end
220
	if Character:FindFirstChild("Torso") == nil then return false end
221
	local Joints = {
222
		Character.Torso:FindFirstChild("Right Shoulder 2"),
223
		Character.Torso:FindFirstChild("Left Shoulder 2"),
224
		Character.Torso:FindFirstChild("Right Hip 2"),
225
		Character.Torso:FindFirstChild("Left Hip 2")
226
	}
227
	local Limbs = {
228
		Character:FindFirstChild("Right Arm"),
229
		Character:FindFirstChild("Left Arm"),
230
		Character:FindFirstChild("Right Leg"),
231
		Character:FindFirstChild("Left Leg")
232
	}
233
	if Joints[Limb] == nil then return false end
234
	if Limbs[Limb] == nil then return false end
235
	if Limb == 1 then
236
		Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
237
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
238
	elseif Limb == 2 then
239
		Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
240
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
241
	elseif Limb == 3 then
242
		Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
243
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
244
	elseif Limb == 4 then
245
		Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
246
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
247
	end
248
end
249
250
251
function EnableLimb(Limb, Character)
252
	if Character == nil then return false end
253
	if Character:FindFirstChild("Torso") == nil then return false end
254
	local Joints = {
255
		Character.Torso:FindFirstChild("Right Shoulder 2"),
256
		Character.Torso:FindFirstChild("Left Shoulder 2"),
257
		Character.Torso:FindFirstChild("Right Hip 2"),
258
		Character.Torso:FindFirstChild("Left Hip 2")
259
	}
260
	local Limbs = {
261
		Character:FindFirstChild("Right Arm"),
262
		Character:FindFirstChild("Left Arm"),
263
		Character:FindFirstChild("Right Leg"),
264
		Character:FindFirstChild("Left Leg")
265
	}
266
	if Joints[Limb] == nil then return false end
267
	if Limbs[Limb] == nil then return false end
268
	if Limb == 1 then
269
		Joints[Limb].Name = "Right Shoulder"
270
	elseif Limb == 2 then
271
		Joints[Limb].Name = "Left Shoulder"
272
	elseif Limb == 3 then
273
		Joints[Limb].Name = "Right Hip"
274
	elseif Limb == 4 then
275
		Joints[Limb].Name = "Left Hip"
276
	end
277
	Animate = Character:FindFirstChild("Animate")
278
	if Animate == nil then return false end
279
	Animate = Animate:Clone()
280
	Character.Animate:Remove()
281
	Animate.Parent = Character
282
end
283
284
285
function Weld(x, y)
286
	local weld = Instance.new("Weld")
287
	weld.Part0 = x
288
	weld.Part1 = y
289
	CJ = CFrame.new(x.Position)
290
	C0 = x.CFrame:inverse() * CJ
291
	C1 = y.CFrame:inverse() * CJ
292
	weld.C0 = C0
293
	weld.C1 = C1
294
	weld.Parent = x
295
end
296
297
298
function tagHumanoid(humanoid)
299
	local tag = Instance.new("ObjectValue")
300
	tag.Name = "creator"
301
	tag.Value = Player
302
	tag.Parent = humanoid
303
	local tag = Instance.new("StringValue")
304
	tag.Name = "creatorType1"
305
	tag.Value = Name
306
	tag.Parent = humanoid
307
	local tag = Instance.new("StringValue")
308
	tag.Name = "creatorType2"
309
	tag.Value = "blown up"
310
	tag.Parent = humanoid
311
end
312
313
314
function untagHumanoid(humanoid)
315
	if humanoid ~= nil then
316
		local tag = humanoid:FindFirstChild("creator")
317
		if tag ~= nil then
318
			tag:Remove()
319
		end
320
		local tag = humanoid:FindFirstChild("creatorType1")
321
		if tag ~= nil then
322
			tag:Remove()
323
		end
324
		local tag = humanoid:FindFirstChild("creatorType2")
325
		if tag ~= nil then
326
			tag:Remove()
327
		end
328
	end
329
end
330
331
332
function fire(v)
333
	if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
334
	if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
335
	if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
336
	local bodyVelocity = Instance.new("BodyVelocity")
337
	bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
338
	bodyVelocity.velocity = v * 75
339
	bodyVelocity.Parent = Player.Character[Name].Handle
340
	wait(0.1)
341
	bodyVelocity:Remove()
342
end
343
344
345
function onButton1Down(mouse)
346
	if selected == false then return end
347
	if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and thrown ~= true then
348
		if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
349
		Button1Down = true
350
		mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
351
		Player.Character[Name].Handle.Pin:Play()
352
		Player.Character[Name].Handle.Light:Play()
353
		Player.Character[Name].Rag.Fire.Enabled = true 
354
		Player.Character[Name].Handle.CanCollide = true
355
		Player.Character[Name].Rag.CanCollide = true  
356
		coroutine.resume(coroutine.create(function()
357
			wait(math.random(3, 6))
358
			if Player.Character:FindFirstChild(Name) ~= nil then
359
				if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
360
					local e = Instance.new("Explosion")
361
					e.BlastPressure = 20
362
					e.BlastRadius = 10
363
					e.Position = Player.Character[Name].Handle.Position
364
					e.Parent = game:GetService("Workspace")
365
					e.Hit:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then tagHumanoid(hit.Parent.Humanoid) delay(1, function() untagHumanoid(hit.Parent.Humanoid) end) end end)
366
					Player.Character[Name].Handle.Explode:Play()
367
					Player.Character[Name].Handle.Transparency = 1
368
					Player.Character[Name].Handle.CanCollide = false
369
					Player.Character[Name].Handle.Pin:Stop()
370
				end
371
			end
372
			wait()
373
			if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
374
				Player.Character.WeaponActivated:Remove()
375
			end
376
			thrown = false
377
			Button1Down = false
378
			selected = true
379
			onDeselected(mouse)
380
			removeParts("holster")
381
			script.Parent:Remove()
382
		end))
383
	end
384
end
385
386
387
function onButton1Up(mouse)
388
	if selected == false then return end
389
	if Button1Down == true and thrown ~= true then
390
		thrown = true
391
		mouse.Icon = "rbxasset://textures\\GunCursor.png"
392
		SetSpeed(1, 2, Player.Character)
393
		SetAngle(1, 0, Player.Character)
394
		EnableLimb(1, Player.Character)
395
		fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
396
	end
397
	Button1Down = false
398
end
399
400
401
function onKeyDown(key, mouse)
402
	if selected == false then return end
403
	key = key:lower()
404
	if key == "q" and Button1Down == false and thrown ~= true then
405
		if mouse.Target == nil then return end
406
		if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
407
			onDeselected(mouse)
408
			removeParts("holster")
409
			script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
410
		end
411
	end
412
end
413
414
415
function onSelected(mouse)
416
	if selected == true then return end
417
	selected = true
418
	mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
419
	while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown == true do
420
		if Player.Character.WeaponActivated.Value == nil then break end
421
		if Player.Character.WeaponActivated.Value.Parent == nil then break end
422
		wait()
423
	end
424
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
425
	removeParts("holster")
426
	makeParts("hand")
427
	local weapon = Instance.new("ObjectValue")
428
	weapon.Name = "WeaponActivated"
429
	weapon.Value = script.Parent
430
	weapon.Parent = Player.Character
431
	DisableLimb(1, Player.Character)
432
	SetAngle(1, math.rad(200), Player.Character)
433
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
434
	mouse.Button1Up:connect(function() onButton1Up(mouse) end)
435
	mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
436
end
437
438
439
function onDeselected(mouse)
440
	if selected == false then return end
441
	selected = false
442
	while Button1Down == true or thrown == true do
443
		wait()
444
	end
445
	if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
446
		if Player.Character.WeaponActivated.Value == script.Parent then
447
			Player.Character.WeaponActivated:Remove()
448
		end
449
	end
450
	while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
451
		if Player.Character.WeaponActivated.Value == nil then break end
452
		if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
453
		wait()
454
	end
455
	removeParts("hand")
456
	makeParts("holster")
457
	SetAngle(1, 0, Player.Character)
458
	EnableLimb(1, Player.Character)
459
end
460
461
462
if script.Parent.className ~= "HopperBin" then
463
	if Player == nil then print("Error: Player not found!") return end
464
	Tool = Instance.new("HopperBin")
465
	Tool.Name = Name
466
	Tool.Parent = Player.Backpack
467
	script.Name = "Main"
468
	script.Parent = Tool
469
elseif script.Parent.className == "HopperBin" then
470
	while script.Parent.Parent.className ~= "Backpack" do
471
		wait()
472
	end
473
	Player = script.Parent.Parent.Parent
474
	makeParts("holster")
475
	script.Parent.Selected:connect(onSelected)
476
	script.Parent.Deselected:connect(onDeselected)
477
end