View difference between Paste ID: 3EkbHfqn and BqqM370J
SHOW: | | - or go back to the newest paste.
1
if script == nil then return end
2
3
4-
Player = game:GetService("Players"):FindFirstChild("MaxFUNroblox1")
4+
Player = game:GetService("Players"):FindFirstChild(owner.Name)
5
Name = "Artillery Beacon"
6
selected = false
7
Button1Down = false
8
thrown = false
9
10
11
function makeParts(format)
12
local beacon = Instance.new("Model")
13
beacon.Name = Name
14
beacon.Parent = Player.Character
15
local pm = Instance.new("Part")
16
pm.Name = "Handle"
17
pm.FormFactor = "Custom"
18
pm.Size = Vector3.new(1, 1, 1)
19
pm.BrickColor = BrickColor.new("Really black")
20
pm.Locked = true
21
pm.TopSurface = 0
22
pm.BottomSurface = 0
23
pm.Parent = beacon
24
local m = Instance.new("SpecialMesh")
25
m.MeshType = "Brick"
26
m.Scale = Vector3.new(0.5, 1.25, 0.2)
27
m.Parent = pm
28
local w = Instance.new("Weld")
29
w.Part0 = pm
30
if format == "hand" then
31
w.Part1 = Player.Character:FindFirstChild("Right Arm")
32
w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
33
w.C1 = CFrame.new()
34
elseif format == "holster" then
35
w.Part1 = Player.Character:FindFirstChild("Torso")
36
w.C0 = CFrame.new(0.7, 0.25, 0.6)
37
w.C1 = CFrame.new()
38
beacon.Name = Name.. " (Holstered)"
39
end
40
w.Parent = pm
41
local s = Instance.new("Sound")
42
s.Name = "Explode"
43
s.SoundId = "http://www.roblox.com/Asset/?id=2101148"
44
s.Volume = 1
45
s.Pitch = 1
46
s.Looped = false
47
s.Parent = pm
48
local s = Instance.new("Sound")
49
s.Name = "Beep"
50
s.SoundId = "http://www.roblox.com/Asset/?id=15666462"
51
s.Volume = 1
52
s.Pitch = 0.75
53
s.Looped = true
54
s.Parent = pm
55
local p = Instance.new("Part")
56
p.Name = "Antenna"
57
p.FormFactor = "Custom"
58
p.Size = Vector3.new(1, 1, 1)
59
p.BrickColor = BrickColor.new("Dark stone grey")
60
p.Transparency = 0
61
p.Locked = true
62
p.TopSurface = 0
63
p.BottomSurface = 0
64
p.Parent = beacon
65
local m = Instance.new("CylinderMesh")
66
m.Scale = Vector3.new(0.1, 0.5, 0.1)
67
m.Parent = p
68
local w = Instance.new("Weld")
69
w.Part0 = p
70
w.Part1 = pm
71
w.C0 = CFrame.new(0.1, -0.85, 0)
72
w.C1 = CFrame.new()
73
w.Parent = p
74
local p = Instance.new("Part")
75
p.Name = "Light"
76
p.FormFactor = "Custom"
77
p.Size = Vector3.new(1, 1, 1)
78
p.BrickColor = BrickColor.new("Bright green")
79
p.Transparency = 1
80
p.Locked = true
81
p.TopSurface = 0
82
p.BottomSurface = 0
83
p.Parent = beacon
84
local m = Instance.new("SpecialMesh")
85
m.MeshType = "Sphere"
86
m.Scale = Vector3.new(0.1, 0.1, 0.1)
87
m.Parent = p
88
local w = Instance.new("Weld")
89
w.Part0 = p
90
w.Part1 = pm
91
w.C0 = CFrame.new(-0.175, -0.64, 0)
92
w.C1 = CFrame.new()
93
w.Parent = p
94
end
95
96
97
function removeParts(format)
98
if format == "hand" then
99
if Player.Character:FindFirstChild(Name) ~= nil then
100
Player.Character[Name]:Remove()
101
end
102
elseif format == "holster" then
103
if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
104
Player.Character[Name.. " (Holstered)"]:Remove()
105
end
106
end
107
end
108
109
110
function SetAngle(Joint, Angle, Character)
111
if Character == nil then return false end
112
local Joints = {
113
Character.Torso:FindFirstChild("Right Shoulder 2"),
114
Character.Torso:FindFirstChild("Left Shoulder 2"),
115
Character.Torso:FindFirstChild("Right Hip 2"),
116
Character.Torso:FindFirstChild("Left Hip 2")
117
}
118
if Joints[Joint] == nil then return false end
119
if Joint == 1 or Joint == 3 then
120
Joints[Joint].DesiredAngle = Angle
121
end
122
if Joint == 2 or Joint == 4 then
123
Joints[Joint].DesiredAngle = -Angle
124
end
125
end
126
127
128
function ForceAngle(Joint, Angle, Character)
129
if Character == nil then return false end
130
local Joints = {
131
Character.Torso:FindFirstChild("Right Shoulder 2"),
132
Character.Torso:FindFirstChild("Left Shoulder 2"),
133
Character.Torso:FindFirstChild("Right Hip 2"),
134
Character.Torso:FindFirstChild("Left Hip 2")
135
}
136
if Joints[Joint] == nil then return false end
137
if Joint == 1 or Joint == 3 then
138
Joints[Joint].DesiredAngle = Angle
139
Joints[Joint].CurrentAngle = Angle
140
end
141
if Joint == 2 or Joint == 4 then
142
Joints[Joint].DesiredAngle = -Angle
143
Joints[Joint].CurrentAngle = -Angle
144
end
145
end
146
147
148
function SetSpeed(Joint, Speed, Character)
149
if Character == nil then return false end
150
local Joints = {
151
Character.Torso:FindFirstChild("Right Shoulder 2"),
152
Character.Torso:FindFirstChild("Left Shoulder 2"),
153
Character.Torso:FindFirstChild("Right Hip 2"),
154
Character.Torso:FindFirstChild("Left Hip 2")
155
}
156
if Joints[Joint] == nil then return false end
157
Joints[Joint].MaxVelocity = Speed
158
end
159
160
161
function DisableLimb(Limb, Character)
162
if Character == nil then return false end
163
if Character:FindFirstChild("Torso") == nil then return false end
164
local Joints = {
165
Character.Torso:FindFirstChild("Right Shoulder"),
166
Character.Torso:FindFirstChild("Left Shoulder"),
167
Character.Torso:FindFirstChild("Right Hip"),
168
Character.Torso:FindFirstChild("Left Hip")
169
}
170
local Limbs = {
171
Character:FindFirstChild("Right Arm"),
172
Character:FindFirstChild("Left Arm"),
173
Character:FindFirstChild("Right Leg"),
174
Character:FindFirstChild("Left Leg")
175
}
176
if Joints[Limb] == nil then return false end
177
if Limbs[Limb] == nil then return false end
178
local Joint = Instance.new("Motor")
179
Joint.Parent = Character.Torso
180
Joint.Part0 = Character.Torso
181
Joint.Part1 = Limbs[Limb]
182
if Limb == 1 then
183
Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
184
Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
185
Joint.Name = "Right Shoulder 2"
186
elseif Limb == 2 then
187
Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
188
Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
189
Joint.Name = "Left Shoulder 2"
190
elseif Limb == 3 then
191
Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
192
Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
193
Joint.Name = "Right Hip 2"
194
elseif Limb == 4 then
195
Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
196
Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
197
Joint.Name = "Left Hip 2"
198
end
199
Joint.MaxVelocity = Joints[Limb].MaxVelocity
200
Joint.CurrentAngle = Joints[Limb].CurrentAngle
201
Joint.DesiredAngle = Joints[Limb].DesiredAngle
202
Joints[Limb]:Remove()
203
end
204
205
206
function ResetLimbCFrame(Limb, Character)
207
if Character == nil then return false end
208
if Character.Parent == nil then return false end
209
if Character:FindFirstChild("Torso") == nil then return false end
210
local Joints = {
211
Character.Torso:FindFirstChild("Right Shoulder 2"),
212
Character.Torso:FindFirstChild("Left Shoulder 2"),
213
Character.Torso:FindFirstChild("Right Hip 2"),
214
Character.Torso:FindFirstChild("Left Hip 2")
215
}
216
local Limbs = {
217
Character:FindFirstChild("Right Arm"),
218
Character:FindFirstChild("Left Arm"),
219
Character:FindFirstChild("Right Leg"),
220
Character:FindFirstChild("Left Leg")
221
}
222
if Joints[Limb] == nil then return false end
223
if Limbs[Limb] == nil then return false end
224
if Limb == 1 then
225
Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
226
Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
227
elseif Limb == 2 then
228
Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
229
Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
230
elseif Limb == 3 then
231
Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
232
Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
233
elseif Limb == 4 then
234
Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
235
Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
236
end
237
end
238
239
240
function EnableLimb(Limb, Character)
241
if Character == nil then return false end
242
if Character:FindFirstChild("Torso") == nil then return false end
243
local Joints = {
244
Character.Torso:FindFirstChild("Right Shoulder 2"),
245
Character.Torso:FindFirstChild("Left Shoulder 2"),
246
Character.Torso:FindFirstChild("Right Hip 2"),
247
Character.Torso:FindFirstChild("Left Hip 2")
248
}
249
local Limbs = {
250
Character:FindFirstChild("Right Arm"),
251
Character:FindFirstChild("Left Arm"),
252
Character:FindFirstChild("Right Leg"),
253
Character:FindFirstChild("Left Leg")
254
}
255
if Joints[Limb] == nil then return false end
256
if Limbs[Limb] == nil then return false end
257
if Limb == 1 then
258
Joints[Limb].Name = "Right Shoulder"
259
elseif Limb == 2 then
260
Joints[Limb].Name = "Left Shoulder"
261
elseif Limb == 3 then
262
Joints[Limb].Name = "Right Hip"
263
elseif Limb == 4 then
264
Joints[Limb].Name = "Left Hip"
265
end
266
Animate = Character:FindFirstChild("Animate")
267
if Animate == nil then return false end
268
Animate = Animate:Clone()
269
Character.Animate:Remove()
270
Animate.Parent = Character
271
end
272
273
274
function Weld(x, y)
275
local weld = Instance.new("Weld")
276
weld.Part0 = x
277
weld.Part1 = y
278
CJ = CFrame.new(x.Position)
279
C0 = x.CFrame:inverse() * CJ
280
C1 = y.CFrame:inverse() * CJ
281
weld.C0 = C0
282
weld.C1 = C1
283
weld.Parent = x
284
end
285
286
287
function tagHumanoid(humanoid)
288
local tag = Instance.new("ObjectValue")
289
tag.Name = "creator"
290
tag.Value = Player
291
tag.Parent = humanoid
292
local tag = Instance.new("StringValue")
293
tag.Name = "creatorType1"
294
tag.Value = Name
295
tag.Parent = humanoid
296
local tag = Instance.new("StringValue")
297
tag.Name = "creatorType2"
298
tag.Value = "blown to pieces"
299
tag.Parent = humanoid
300
end
301
302
303
function untagHumanoid(humanoid)
304
if humanoid ~= nil then
305
local tag = humanoid:FindFirstChild("creator")
306
if tag ~= nil then
307
tag:Remove()
308
end
309
local tag = humanoid:FindFirstChild("creatorType1")
310
if tag ~= nil then
311
tag:Remove()
312
end
313
local tag = humanoid:FindFirstChild("creatorType2")
314
if tag ~= nil then
315
tag:Remove()
316
end
317
end
318
end
319
320
321
function fire(v)
322
if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
323
if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
324
if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
325
local bodyVelocity = Instance.new("BodyVelocity")
326
bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
327
bodyVelocity.velocity = v * 75
328
bodyVelocity.Parent = Player.Character[Name].Handle
329
wait(0.1)
330
bodyVelocity:Remove()
331
end
332
333
334
function onButton1Down(mouse)
335
if selected == false then return end
336
if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and thrown ~= true then
337
if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
338
if Player.Character[Name]:FindFirstChild("Antenna") == nil then return end
339
if Player.Character[Name]:FindFirstChild("Light") == nil then return end
340
Button1Down = true
341
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
342
Player.Character[Name].Light.Transparency = 0.4
343
coroutine.resume(coroutine.create(function(target)
344
local pos1 = target.Position
345
local pos2 = pos1
346
while true do
347
if target == nil then return end
348
if target.Parent == nil then return end
349
pos2 = pos1
350
pos1 = target.Position
351
local trail = Instance.new("Part")
352
trail.BrickColor = target.BrickColor
353
trail.TopSurface = 0
354
trail.BottomSurface = 0
355
trail.FormFactor = target.FormFactor
356
trail.Size = Vector3.new(1, 1, 1)
357
trail.Reflectance = 0
358
trail.Transparency = 0.3
359
trail.Anchored = true
360
trail.CanCollide = false
361
trail.CFrame = CFrame.new((pos1 + pos2) / 2, pos2)
362
trail.Parent = Workspace
363
local mesh = Instance.new("SpecialMesh")
364
mesh.MeshType = "Brick"
365
mesh.Scale = Vector3.new(0.2, 0.2, (pos2 - pos1).magnitude)
366
mesh.Parent = trail
367
coroutine.resume(coroutine.create(function(part) for i = 3, 10, 1 do part.Transparency = i / 10 wait(0.1) end part:Remove() end), trail)
368
wait()
369
end
370
end), Player.Character[Name].Light)
371
wait(0.5)
372
Player.Character[Name].Handle.Beep:Play()
373
Player.Character[Name].Light.BrickColor = BrickColor.new("Bright orange")
374
coroutine.resume(coroutine.create(function()
375
wait(3)
376
if Player.Character:FindFirstChild(Name) ~= nil then
377
if Player.Character[Name]:FindFirstChild("Light") ~= nil then Player.Character[Name].Light.BrickColor = BrickColor.new("Really red") end
378
if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep.Pitch = 1.25 end
379
local position = Player.Character[Name].Handle.Position
380
local s = Player.Character[Name].Handle.Explode:Clone()
381
coroutine.resume(coroutine.create(function()
382
local weld1 = Player.Character[Name].Light:FindFirstChild("Weld")
383
local weld2 = Player.Character[Name].Antenna:FindFirstChild("Weld")
384
if weld1 == nil then return end
385
if weld2 == nil then return end
386
local weld1c = weld1:Clone()
387
local weld2c = weld2:Clone()
388
while true do
389
if Player.Character ~= nil then
390
if Player.Character:FindFirstChild(Name) ~= nil then
391
if weld1.Parent == nil then
392
if Player.Character[Name]:FindFirstChild("Light") ~= nil then
393
weld1c:Clone().Parent = Player.Character[Name].Light
394
Player.Character[Name]:MakeJoints()
395
end
396
end
397
if weld2.Parent == nil then
398
if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
399
weld2c:Clone().Parent = Player.Character[Name].Antenna
400
Player.Character[Name]:MakeJoints()
401
end
402
end
403
end
404
end
405
wait()
406
end
407
end))
408
for i = 0, math.random(30, 50) do
409
if Player.Character:FindFirstChild("Humanoid") ~= nil then
410
if Player.Character.Humanoid.Health <= 0 then break end
411
local shell = Instance.new("Part")
412
shell.Name = "Artillery Shell"
413
shell.Anchored = true
414
shell.BrickColor = BrickColor.new("Medium stone grey")
415
shell.FormFactor = "Custom"
416
shell.Size = Vector3.new(2, 5, 2)
417
shell.TopSurface = 0
418
shell.BottomSurface = 0
419
shell.Parent = Workspace
420
coroutine.resume(coroutine.create(function(part)
421
local offset = Vector3.new(math.random(-50, 50), math.random(-10, 10), math.random(-50, 50))
422
for i = 1000, 0, -25 do
423
part.CFrame = CFrame.new((position + offset) + Vector3.new(0, i, 0))
424
wait()
425
end
426
local e = Instance.new("Explosion")
427
e.Position = part.Position
428
e.BlastPressure = 500000
429
e.BlastRadius = 25
430
e.Parent = Workspace
431
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)
432
local s2 = s:Clone()
433
s2.Pitch = math.random(70, 90) / 100
434
s2.Parent = Workspace
435
s2:Play()
436
part:Remove()
437
end), shell)
438
end
439
wait(math.random(1, 5) / 10)
440
end
441
if Player.Character:FindFirstChild(Name) ~= nil then if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep:Stop() end end
442
end
443
wait(1)
444
removeParts("hand")
445
wait(1)
446
if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
447
Player.Character.WeaponActivated:Remove()
448
end
449
thrown = false
450
Button1Down = false
451
selected = true
452
onDeselected(mouse)
453
removeParts("holster")
454
script.Parent:Remove()
455
end))
456
end
457
end
458
459
460
function onButton1Up(mouse)
461
if selected == false then return end
462
if Button1Down == true and thrown ~= true then
463
thrown = true
464
mouse.Icon = "rbxasset://textures\\GunCursor.png"
465
SetSpeed(1, 0.75, Player.Character)
466
SetAngle(1, 0, Player.Character)
467
EnableLimb(1, Player.Character)
468
fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
469
end
470
Button1Down = false
471
end
472
473
474
function onKeyDown(key, mouse)
475
if selected == false then return end
476
key = key:lower()
477
if key == "q" and Button1Down == false and thrown ~= true then
478
if mouse.Target == nil then return end
479
if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
480
onDeselected(mouse)
481
removeParts("holster")
482
script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
483
end
484
end
485
end
486
487
488
function onSelected(mouse)
489
if selected == true then return end
490
selected = true
491
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
492
while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown == true do
493
if Player.Character.WeaponActivated.Value == nil then break end
494
if Player.Character.WeaponActivated.Value.Parent == nil then break end
495
wait()
496
end
497
mouse.Icon = "rbxasset://textures\\GunCursor.png"
498
removeParts("holster")
499
makeParts("hand")
500
local weapon = Instance.new("ObjectValue")
501
weapon.Name = "WeaponActivated"
502
weapon.Value = script.Parent
503
weapon.Parent = Player.Character
504
DisableLimb(1, Player.Character)
505
SetAngle(1, math.rad(200), Player.Character)
506
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
507
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
508
mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
509
end
510
511
512
function onDeselected(mouse)
513
if selected == false then return end
514
selected = false
515
while Button1Down == true or thrown == true do
516
wait()
517
end
518
if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
519
if Player.Character.WeaponActivated.Value == script.Parent then
520
Player.Character.WeaponActivated:Remove()
521
end
522
end
523
while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
524
if Player.Character.WeaponActivated.Value == nil then break end
525
if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
526
wait()
527
end
528
removeParts("hand")
529
makeParts("holster")
530
SetAngle(1, 0, Player.Character)
531
EnableLimb(1, Player.Character)
532
end
533
534
535
if script.Parent.ClassName ~= "HopperBin" then
536
if Player == nil then print("Error: Player not found!") return end
537
Tool = Instance.new("HopperBin")
538
Tool.Name = Name
539
Tool.Parent = Player.Backpack
540
script.Name = "Main"
541
script.Parent = Tool
542
elseif script.Parent.ClassName == "HopperBin" then
543
while script.Parent.Parent.ClassName ~= "Backpack" do
544
wait()
545
end
546
Player = script.Parent.Parent.Parent
547
makeParts("holster")
548
script.Parent.Selected:connect(onSelected)
549
script.Parent.Deselected:connect(onDeselected)
550
end