View difference between Paste ID: CnTZe7HR and WNcQb4TK
SHOW: | | - or go back to the newest paste.
1-
local runDummyScript = function(f,scri)
1+
--https://github.com/Mokiros/roblox-FE-compatibility
2
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
3
local Player,game,owner = owner,game
4
local RealPlayer = Player
5
do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end local runDummyScript = function(f,scri)
6
local oldenv = getfenv(f)
7
local newenv = setmetatable({}, {
8
__index = function(_, k)
9
if k:lower() == 'script' then
10
return scri
11
else
12
return oldenv[k]
13
end
14
end
15
})
16
setfenv(f, newenv)
17
ypcall(function() f() end)
18
end
19
cors = {}
20
mas = Instance.new("Model",game:GetService("Lighting")) 
21
mas.Name = "CompiledModel"
22
o1 = Instance.new("Tool")
23
o2 = Instance.new("Part")
24
o4 = Instance.new("Decal")
25
o5 = Instance.new("Decal")
26
o6 = Instance.new("Sound")
27
o7 = Instance.new("Sound")
28
o8 = Instance.new("PointLight")
29
o9 = Instance.new("LocalScript")
30
o10 = Instance.new("LocalScript")
31
o11 = Instance.new("Sound")
32
o1.Name = "Arm Cannon"
33
o1.Parent = mas
34
o1.GripForward = Vector3.new(1, -0, -0)
35
o1.GripRight = Vector3.new(0, 0, 1)
36
o1.ToolTip = "Based off of Metroid"
37
o2.Name = "Handle"
38
o2.Parent = o1
39
o2.Material = Enum.Material.SmoothPlastic
40
o2.BrickColor = BrickColor.new("Shamrock")
41
o2.Position = Vector3.new(1.5150001, 5.50499964, -0.914999843)
42
o2.Rotation = Vector3.new(-0, -90, 0)
43
o2.Size = Vector3.new(1.82999992, 1.13000011, 1.08999991)
44
o2.CFrame = CFrame.new(1.5150001, 5.50499964, -0.914999843, 0, 0, -1.00000024, 0, 1, 0, 1.00000024, 0, 0)
45
o2.BackSurface = Enum.SurfaceType.Weld
46
o2.BottomSurface = Enum.SurfaceType.Weld
47
o2.FrontSurface = Enum.SurfaceType.Weld
48
o2.LeftSurface = Enum.SurfaceType.Weld
49
o2.RightSurface = Enum.SurfaceType.Weld
50
o2.TopSurface = Enum.SurfaceType.Weld
51
o2.Color = Color3.new(0.356863, 0.603922, 0.298039)
52
o2.Position = Vector3.new(1.5150001, 5.50499964, -0.914999843)
53
o4.Parent = o2
54
o4.Texture = "http://www.roblox.com/asset/?id=22285987"
55
o4.Face = Enum.NormalId.Left
56
o5.Parent = o2
57
o5.Texture = "http://www.roblox.com/asset/?id=22285987"
58
o5.Face = Enum.NormalId.Right
59
o6.Name = "Fire"
60
o6.Parent = o2
61
o6.SoundId = "http://www.roblox.com/asset?id=130113322"
62
o7.Name = "Reload"
63
o7.Parent = o2
64
o7.SoundId = "http://www.roblox.com/asset?id=130113370"
65
o8.Parent = o2
66
o8.Color = Color3.new(1, 1, 0)
67
o8.Range = 6
68
o9.Name = "MouseIcon"
69
o9.Parent = o1
70
table.insert(cors,coroutine.create(function()
71
wait()
72
runDummyScript(function()
73
local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
74
local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
75
76
local Tool = script.Parent
77
78
local Mouse = nil
79
80
local function UpdateIcon()
81
	if Mouse then
82
		Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
83
	end
84
end
85
86
local function OnEquipped(mouse)
87
	Mouse = mouse
88
	UpdateIcon()
89
end
90
91
local function OnChanged(property)
92
	if property == 'Enabled' then
93
		UpdateIcon()
94
	end
95
end
96
97
Tool.Equipped:connect(OnEquipped)
98
Tool.Changed:connect(OnChanged)
99
100
end,o9)
101
end))
102
o10.Name = "ToolScript"
103
o10.Parent = o1
104
table.insert(cors,coroutine.create(function()
105
wait()
106
runDummyScript(function()
107
-----------------
108
--| Constants |--
109
-----------------
110
111
local SHOT_SPEED = 100
112
local SHOT_TIME = 1
113
114
local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)
115
116
-----------------
117
--| Variables |--
118
-----------------
119
120
local PlayersService = Game:GetService('Players')
121
local DebrisService = Game:GetService('Debris')
122
123
local Tool = script.Parent
124
local Handle = Tool:WaitForChild('Handle')
125
126
local FireSound = Handle:WaitForChild('Fire')
127
local ReloadSound = Handle:WaitForChild('Reload')
128
local HitFadeSound = script:WaitForChild('HitFade')
129
130
local PointLight = Handle:WaitForChild('PointLight')
131
132
local Character = nil
133
local Humanoid = nil
134
local Player = nil
135
136
local BaseShot = nil
137
138
-----------------
139
--| Functions |--
140
-----------------
141
142
-- Returns a character ancestor and its Humanoid, or nil
143
local function FindCharacterAncestor(subject)
144
	if subject and subject ~= Workspace then
145
		local humanoid = subject:FindFirstChild('Humanoid')
146
		if humanoid then
147
			return subject, humanoid
148
		else
149
			return FindCharacterAncestor(subject.Parent)
150
		end
151
	end
152
	return nil
153
end
154
155
-- Removes any old creator tags and applies new ones to the specified target
156
local function ApplyTags(target)
157
	while target:FindFirstChild('creator') do
158
		target.creator:Destroy()
159
	end
160
161
	local creatorTag = Instance.new('ObjectValue')
162
	creatorTag.Value = Player
163
	creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
164
165
	local iconTag = Instance.new('StringValue')
166
	iconTag.Value = Tool.TextureId
167
	iconTag.Name = 'icon'
168
169
	iconTag.Parent = creatorTag
170
	creatorTag.Parent = target
171
	DebrisService:AddItem(creatorTag, 4)
172
end
173
174
-- Returns all objects under instance with Transparency
175
local function GetTransparentsRecursive(instance, partsTable)
176
	local partsTable = partsTable or {}
177
	for _, child in pairs(instance:GetChildren()) do
178
		if child:IsA('BasePart') or child:IsA('Decal') then
179
			table.insert(partsTable, child)
180
		end
181
		GetTransparentsRecursive(child, partsTable)
182
	end
183
	return partsTable
184
end
185
186
local function SelectionBoxify(instance)
187
	local selectionBox = Instance.new('SelectionBox')
188
	selectionBox.Adornee = instance
189
	selectionBox.Color = BrickColor.new('New Yeller')
190
	selectionBox.Parent = instance
191
	return selectionBox
192
end
193
194
local function Light(instance)
195
	local light = PointLight:Clone()
196
	light.Range = light.Range + 2
197
	light.Parent = instance
198
end
199
200
local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
201
	repeat
202
		local lastObject = nil
203
		for _, object in pairs(objectsWithTransparency) do
204
			object.Transparency = object.Transparency + fadeIncrement
205
			lastObject = object
206
		end
207
		wait()
208
	until lastObject.Transparency >= 1 or not lastObject
209
end
210
211
local function Dematerialize(character, humanoid, firstPart)
212
	humanoid.WalkSpeed = 0
213
214
	local parts = {}
215
	for _, child in pairs(character:GetChildren()) do
216
		if child:IsA('BasePart') then
217
			child.Anchored = true
218
			table.insert(parts, child)
219
		elseif child:IsA('LocalScript') or child:IsA('Script') then
220
			child:Destroy()
221
		end
222
	end
223
224
	local selectionBoxes = {}
225
226
	local firstSelectionBox = SelectionBoxify(firstPart)
227
	Light(firstPart)
228
	wait(0.05)
229
230
	for _, part in pairs(parts) do
231
		if part ~= firstPart then
232
			table.insert(selectionBoxes, SelectionBoxify(part))
233
			Light(part)
234
		end
235
	end
236
237
	local objectsWithTransparency = GetTransparentsRecursive(character)
238
	FadeOutObjects(objectsWithTransparency, 0.1)
239
240
	wait(0.5)
241
242
	humanoid.Health = 0
243
	DebrisService:AddItem(character, 2)
244
245
	local fadeIncrement = 0.05
246
	Delay(0.2, function()
247
		FadeOutObjects({firstSelectionBox}, fadeIncrement)
248
		if character then
249
			character:Destroy()
250
		end
251
	end)
252
	FadeOutObjects(selectionBoxes, fadeIncrement)
253
end
254
255
local function OnTouched(shot, otherPart)
256
	local character, humanoid = FindCharacterAncestor(otherPart)
257
	if character and humanoid and character ~= Character then
258
		ApplyTags(humanoid)
259
		if shot then
260
			local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
261
			if hitFadeSound then
262
				hitFadeSound.Parent = humanoid.Torso
263
				hitFadeSound:Play()
264
			end
265
			shot:Destroy()
266
		end
267
		Dematerialize(character, humanoid, otherPart)
268
	end
269
end
270
271
local function OnEquipped()
272
	Character = Tool.Parent
273
	Humanoid = Character:WaitForChild('Humanoid')
274
	Player = PlayersService:GetPlayerFromCharacter(Character)
275
end
276
277
local function OnActivated()
278
	if Tool.Enabled and Humanoid.Health > 0 then
279
		Tool.Enabled = false
280
281
		FireSound:Play()
282
283
		local handleCFrame = Handle.CFrame
284
		local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
285
		local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
286
287
		local laserShotClone = BaseShot:Clone()
288
		laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
289
		local bodyVelocity = Instance.new('BodyVelocity')
290
		bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
291
		bodyVelocity.Parent = laserShotClone
292
		laserShotClone.Touched:connect(function(otherPart)
293
			OnTouched(laserShotClone, otherPart)
294
		end)
295
		DebrisService:AddItem(laserShotClone, SHOT_TIME)
296
		laserShotClone.Parent = Tool
297
298
		wait(0.6) -- FireSound length
299
300
		ReloadSound:Play()
301
		wait(0.75) -- ReloadSound length
302
303
		Tool.Enabled = true
304
	end
305
end
306
307
local function OnUnequipped()
308
	
309
end
310
311
--------------------
312
--| Script Logic |--
313
--------------------
314
315
BaseShot = Instance.new('Part')
316
BaseShot.Name = 'Effect'
317
BaseShot.FormFactor = Enum.FormFactor.Custom
318
BaseShot.Size = Vector3.new(0.2, 0.2, 3)
319
BaseShot.CanCollide = false
320
BaseShot.BrickColor = BrickColor.new('Toothpaste')
321
SelectionBoxify(BaseShot)
322
Light(BaseShot)
323
HitFadeSound:Clone().Parent = BaseShot
324
325
Tool.Equipped:connect(OnEquipped)
326
Tool.Unequipped:connect(OnUnequipped)
327
Tool.Activated:connect(OnActivated)
328
329
end,o10)
330
end))
331
o11.Name = "HitFade"
332
o11.Parent = o10
333
o11.SoundId = "http://www.roblox.com/asset?id=130113415"
334
mas.Parent = workspace
335
mas:MakeJoints()
336
local mas1 = mas:GetChildren()
337
for i=1,#mas1 do
338
	mas1[i].Parent = game:GetService("Players").LocalPlayer.Backpack 
339
	ypcall(function() mas1[i]:MakeJoints() end)
340
end
341
mas:Destroy()
342
for i=1,#cors do
343
coroutine.resume(cors[i])
344
end