· 7 years ago · Feb 14, 2019, 03:12 PM
1-- This script has convert to FE by who i don't know?
2
3-----------------------------------------------------
4if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
5local Player,game,owner = owner,game
6local RealPlayer = Player
7do
8 print("FE Compatibility code by Mokiros | Showcase by Bacon Hair!")
9 local rp = RealPlayer
10 script.Parent = rp.Character
11
12 --RemoteEvent for communicating
13 local Event = Instance.new("RemoteEvent")
14 Event.Name = "UserInput_Event"
15
16 --Fake event to make stuff like Mouse.KeyDown work
17 local function fakeEvent()
18 local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
19 t.connect = t.Connect
20 return t
21 end
22
23 --Creating fake input objects with fake variables
24 local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
25 local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
26 local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
27 CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
28 end}
29 --Merged 2 functions into one by checking amount of arguments
30 CAS.UnbindAction = CAS.BindAction
31
32 --This function will trigger the events that have been :Connect()'ed
33 local function te(self,ev,...)
34 local t = m[ev]
35 if t and t._fakeEvent then
36 for _,f in pairs(t.Functions) do
37 f(...)
38 end
39 end
40 end
41 m.TrigEvent = te
42 UIS.TrigEvent = te
43
44 Event.OnServerEvent:Connect(function(plr,io)
45 if plr~=rp then return end
46 m.Target = io.Target
47 m.Hit = io.Hit
48 if not io.isMouse then
49 local b = io.UserInputState == Enum.UserInputState.Begin
50 if io.UserInputType == Enum.UserInputType.MouseButton1 then
51 return m:TrigEvent(b and "Button1Down" or "Button1Up")
52 end
53 for _,t in pairs(CAS.Actions) do
54 for _,k in pairs(t.Keys) do
55 if k==io.KeyCode then
56 t.Function(t.Name,io.UserInputState,io)
57 end
58 end
59 end
60 m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
61 UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
62 end
63 end)
64 Event.Parent = NLS([==[
65 local Player = game:GetService("Players").LocalPlayer
66 local Event = script:WaitForChild("UserInput_Event")
67
68 local Mouse = Player:GetMouse()
69 local UIS = game:GetService("UserInputService")
70 local input = function(io,a)
71 if a then return end
72 --Since InputObject is a client-side instance, we create and pass table instead
73 Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
74 end
75 UIS.InputBegan:Connect(input)
76 UIS.InputEnded:Connect(input)
77
78 local h,t
79 --Give the server mouse data 30 times every second, but only if the values changed
80 --If player is not moving their mouse, client won't fire events
81 while wait(1/30) do
82 if h~=Mouse.Hit or t~=Mouse.Target then
83 h,t=Mouse.Hit,Mouse.Target
84 Event:FireServer({isMouse=true,Target=t,Hit=h})
85 end
86 end]==],Player.Character)
87
88 ----Sandboxed game object that allows the usage of client-side methods and services
89 --Real game object
90 local _rg = game
91
92 --Metatable for fake service
93 local fsmt = {
94 __index = function(self,k)
95 local s = rawget(self,"_RealService")
96 if s then return s[k] end
97 end,
98 __newindex = function(self,k,v)
99 local s = rawget(self,"_RealService")
100 if s then s[k]=v end
101 end,
102 __call = function(self,...)
103 local s = rawget(self,"_RealService")
104 if s then return s(...) end
105 end
106 }
107 local function FakeService(t,RealService)
108 t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
109 return setmetatable(t,fsmt)
110 end
111
112 --Fake game object
113 local g = {
114 GetService = function(self,s)
115 return self[s]
116 end,
117 Players = FakeService({
118 LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
119 },"Players"),
120 UserInputService = FakeService(UIS,"UserInputService"),
121 ContextActionService = FakeService(CAS,"ContextActionService"),
122 }
123 rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
124 g.service = g.GetService
125
126 g.RunService = FakeService({
127 RenderStepped = _rg:GetService("RunService").Heartbeat,
128 BindToRenderStep = function(self,name,_,fun)
129
130 end,
131 UnbindFromRenderStep = function(self,name)
132 self._btrs[name]:Disconnect()
133 end,
134 },"RunService")
135
136 setmetatable(g,{
137 __index=function(self,s)
138 return _rg:GetService(s) or typeof(_rg[s])=="function"
139 and function(_,...)return _rg[s](_rg,...)end or _rg[s]
140 end,
141 __newindex = fsmt.__newindex,
142 __call = fsmt.__call
143 })
144 --Changing owner to fake player object to support owner:GetMouse()
145 game,owner = g,g.Players.LocalPlayer
146end
147--Created with ttyyuu12345's compiler
148--Errors: TouchTransmitter,LocalScript,ModuleScript
149Create = function(itemClass,tabl)
150local item = Instance.new(itemClass)
151for i,v in pairs(tabl) do
152local a,b = ypcall(function() return item[i] end)
153if a then
154item[i] = tabl[i]
155end
156end
157return item
158end
159function runDummyScript(f,scri)
160local oldenv = getfenv(f)
161local newenv = setmetatable({}, {
162__index = function(_, k)
163if k:lower() == 'script' then
164return scri
165else
166return oldenv[k]
167end
168end
169})
170setfenv(f, newenv)
171ypcall(function() f() end)
172end
173cors = {}
174mas = Instance.new("Model",game:GetService("Lighting"))
175mas.Name = "CompiledModel"
176o1 = Create("Tool",{
177["Name"] = "RocketLauncher",
178["Parent"] = mas,
179["TextureId"] = "http://www.roblox.com/asset/?id=90021376",
180["GripForward"] = Vector3.new(1, -0, -0),
181["GripPos"] = Vector3.new(0.699999988, 0, -0.5),
182["GripRight"] = Vector3.new(0, -1, 0),
183["GripUp"] = Vector3.new(0, 0, 1),
184["CanBeDropped"] = false,
185})
186o2 = Create("Part",{
187["Name"] = "Handle",
188["Parent"] = o1,
189["Rotation"] = Vector3.new(-89.9963913, 0, -0),
190["CFrame"] = CFrame.new(0, 0, 0, 1, 0, 0, 0, 6.30170107e-005, 1.00000024, 0, -1.00000024, 6.30170107e-005),
191["CanCollide"] = false,
192["FormFactor"] = Enum.FormFactor.Custom,
193["Size"] = Vector3.new(4.92000628, 0.740000546, 0.839999795),
194["BottomSurface"] = Enum.SurfaceType.Smooth,
195["TopSurface"] = Enum.SurfaceType.Smooth,
196})
197o3 = Create("SpecialMesh",{
198["Parent"] = o2,
199["MeshId"] = "rbxasset://fonts/rocketlauncher.mesh",
200["Scale"] = Vector3.new(0.75, 0.75, 0.75),
201["TextureId"] = "rbxasset://textures/rocketlaunchertex.png",
202["MeshType"] = Enum.MeshType.FileMesh,
203})
204o5 = Create("Script",{
205["Parent"] = o1,
206})
207table.insert(cors,coroutine.create(function()
208wait()
209runDummyScript(function()
210local tool = script.Parent
211local canFire = true
212local gunWeld
213
214-----------------
215--| Constants |--
216-----------------
217
218local GRAVITY_ACCELERATION = 196.2
219
220local RELOAD_TIME = tool.Configurations.ReloadTime.Value -- Seconds until tool can be used again
221local ROCKET_SPEED = tool.Configurations.RocketSpeed.Value -- Speed of the projectile
222
223local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
224local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
225local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
226
227local RocketScript = script:WaitForChild('Rocket')
228local SwooshSound = script:WaitForChild('Swoosh')
229local BoomSound = script:WaitForChild('Boom')
230
231local attackCooldown = tool.Configurations.AttackCooldown.Value
232local damage = tool.Configurations.Damage.Value
233local reloadTime = tool.Configurations.ReloadTime.Value
234
235local function createEvent(eventName)
236 local event = game.ReplicatedStorage:FindFirstChild(eventName)
237 if not event then
238 event = Instance.new("RemoteEvent", game.ReplicatedStorage)
239 event.Name = eventName
240 end
241 return event
242end
243
244local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
245local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
246local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
247local fireEvent = createEvent("ROBLOX_RocketFireEvent")
248
249updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
250 local character = player.Character
251 character.Torso.Neck.C0 = neckC0
252 character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
253 gunWeld = character:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
254end)
255
256equipEvent.OnServerEvent:connect(function(player)
257 player.Character.Humanoid.AutoRotate = false
258end)
259
260unequipEvent.OnServerEvent:connect(function(player)
261 player.Character.Humanoid.AutoRotate = true
262end)
263
264--NOTE: We create the rocket once and then clone it when the player fires
265local Rocket = Instance.new('Part') do
266 -- Set up the rocket part
267 Rocket.Name = 'Rocket'
268 Rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
269 Rocket.Size = ROCKET_PART_SIZE
270 Rocket.CanCollide = false
271
272 -- Add the mesh
273 local mesh = Instance.new('SpecialMesh', Rocket)
274 mesh.MeshId = MISSILE_MESH_ID
275 mesh.Scale = MISSILE_MESH_SCALE
276
277 -- Add fire
278 local fire = Instance.new('Fire', Rocket)
279 fire.Heat = 5
280 fire.Size = 2
281
282 -- Add a force to counteract gravity
283 local bodyForce = Instance.new('BodyForce', Rocket)
284 bodyForce.Name = 'Antigravity'
285 bodyForce.force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
286
287 -- Clone the sounds and set Boom to PlayOnRemove
288 local swooshSoundClone = SwooshSound:Clone()
289 swooshSoundClone.Parent = Rocket
290 local boomSoundClone = BoomSound:Clone()
291 boomSoundClone.PlayOnRemove = true
292 boomSoundClone.Parent = Rocket
293
294 -- Finally, clone the rocket script and enable it
295-- local rocketScriptClone = RocketScript:Clone()
296-- rocketScriptClone.Parent = Rocket
297-- rocketScriptClone.Disabled = false
298end
299
300
301fireEvent.OnServerEvent:connect(function(player, target)
302 if canFire and player.Character == tool.Parent then
303 canFire = false
304
305 -- Create a clone of Rocket and set its color
306 local rocketClone = Rocket:Clone()
307 --game.Debris:AddItem(rocketClone, 30)
308 rocketClone.BrickColor = player.TeamColor
309 rocketClone.Touched:connect(function(hit)
310 if hit and hit.Parent and hit.Parent ~= player.Character and hit.Parent ~= tool then
311 local explosion = Instance.new("Explosion", game.Workspace)
312 explosion.Position = rocketClone.Position
313 rocketClone:Destroy()
314 end
315 end)
316
317 spawn(function()
318 wait(30)
319 if rocketClone then rocketClone:Destroy() end
320 end)
321
322 -- Position the rocket clone and launch!
323 local spawnPosition = (tool.Handle.CFrame * CFrame.new(2, 0, 0)).p
324 rocketClone.CFrame = CFrame.new(spawnPosition, target) --NOTE: This must be done before assigning Parent
325 rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
326 rocketClone.Parent = game.Workspace
327
328 -- Attach creator tags to the rocket early on
329 local creatorTag = Instance.new('ObjectValue', rocketClone)
330 creatorTag.Value = player
331 creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
332 local iconTag = Instance.new('StringValue', creatorTag)
333 iconTag.Value = tool.TextureId
334 iconTag.Name = 'icon'
335
336 delay(attackCooldown, function()
337 canFire = true
338 end)
339 end
340end)
341end,o5)
342end))
343o6 = Create("Sound",{
344["Name"] = "Boom",
345["Parent"] = o5,
346["SoundId"] = "rbxasset://sounds/collide.wav",
347["Volume"] = 1,
348})
349o7 = Create("Sound",{
350["Name"] = "Swoosh",
351["Parent"] = o5,
352["SoundId"] = "rbxasset://sounds/Rocket whoosh 01.wav",
353["Volume"] = 0.69999998807907,
354["Looped"] = true,
355})
356o8 = Create("Script",{
357["Name"] = "Rocket",
358["Parent"] = o5,
359})
360table.insert(cors,coroutine.create(function()
361wait()
362runDummyScript(function()
363-----------------
364--| Constants |--
365-----------------
366local BLAST_RADIUS = script.Parent.Parent.Configurations.BlastRadius.Value -- Blast radius of the explosion
367local BLAST_DAMAGE = script.Parent.Parent.Configurations.Damage.Value -- Amount of damage done to players
368local BLAST_FORCE = script.Parent.Parent.Configurations.BlastForce.Value -- Amount of force applied to parts
369
370local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
371--NOTE: Keys must be lowercase, values must evaluate to true
372
373-----------------
374--| Variables |--
375-----------------
376
377local DebrisService = game:GetService('Debris')
378local PlayersService = game:GetService('Players')
379
380local Rocket = script.Parent
381
382local CreatorTag = Rocket:WaitForChild('creator')
383local SwooshSound = Rocket:WaitForChild('Swoosh')
384
385-----------------
386--| Functions |--
387-----------------
388
389-- Removes any old creator tags and applies a new one to the target
390local function ApplyTags(target)
391 while target:FindFirstChild('creator') do
392 target.creator:Destroy()
393 end
394
395 local creatorTagClone = CreatorTag:Clone()
396 DebrisService:AddItem(creatorTagClone, 1.5)
397 creatorTagClone.Parent = target
398end
399
400-- Returns the ancestor that contains a Humanoid, if it exists
401local function FindCharacterAncestor(subject)
402 if subject and subject ~= game.Workspace then
403 local humanoid = subject:FindFirstChild('Humanoid')
404 if humanoid then
405 return subject, humanoid
406 else
407 return FindCharacterAncestor(subject.Parent)
408 end
409 end
410 return nil
411end
412
413-- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
414local function OnExplosionHit(hitPart, hitDistance, blastCenter)
415 if hitPart and hitDistance then
416 local character, humanoid = FindCharacterAncestor(hitPart.Parent)
417
418 if character then
419 local myPlayer = CreatorTag.Value
420 if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
421 local player = PlayersService:GetPlayerFromCharacter(character)
422 if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
423 return
424 end
425 end
426 end
427
428 if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
429 if hitPart.Name == 'Torso' then
430 ApplyTags(humanoid)
431 humanoid:TakeDamage(BLAST_DAMAGE)
432 end
433 else -- Loose parts and dead parts are blasted
434 if hitPart.Name ~= 'Handle' then
435 hitPart:BreakJoints()
436 local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
437 blastForce.force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
438 DebrisService:AddItem(blastForce, 0.1)
439 end
440 end
441 end
442end
443
444local function OnTouched(otherPart)
445 if Rocket and otherPart then
446 -- Fly through anything in the ignore list
447 if IGNORE_LIST[string.lower(otherPart.Name)] then
448 return
449 end
450
451 local myPlayer = CreatorTag.Value
452 if myPlayer then
453 -- Fly through the creator
454 if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
455 return
456 end
457
458 -- Fly through friendlies
459 if not myPlayer.Neutral then
460 local character = FindCharacterAncestor(otherPart.Parent)
461 local player = PlayersService:GetPlayerFromCharacter(character)
462 if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
463 return
464 end
465 end
466 end
467
468 -- Fly through terrain water
469 if otherPart == game.Workspace.Terrain then
470 --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
471 local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
472 local cellLocation = game.Workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
473 local cellMaterial = game.Workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
474 if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
475 return
476 end
477 end
478
479 -- Create the explosion
480 local explosion = Instance.new('Explosion')
481 explosion.BlastPressure = 0 -- Completely safe explosion
482 explosion.BlastRadius = BLAST_RADIUS
483 explosion.ExplosionType = Enum.ExplosionType.NoCraters
484 explosion.Position = Rocket.Position
485 explosion.Parent = game.Workspace
486
487 -- Connect custom logic for the explosion
488 explosion.Hit:connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
489
490 -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
491 script.Parent = explosion
492 CreatorTag.Parent = script
493 Rocket:Destroy()
494 end
495end
496
497--------------------
498--| Script Logic |--
499--------------------
500
501SwooshSound:Play()
502
503Rocket.Touched:connect(OnTouched)
504
505end,o8)
506end))
507o10 = Create("Configuration",{
508["Name"] = "Configurations",
509["Parent"] = o1,
510})
511o11 = Create("NumberValue",{
512["Name"] = "AttackCooldown",
513["Parent"] = o10,
514["Value"] = 3,
515})
516o12 = Create("IntValue",{
517["Name"] = "Damage",
518["Parent"] = o10,
519["Value"] = 60,
520})
521o13 = Create("NumberValue",{
522["Name"] = "ReloadTime",
523["Parent"] = o10,
524["Value"] = 1,
525})
526o14 = Create("IntValue",{
527["Name"] = "BlastForce",
528["Parent"] = o10,
529["Value"] = 1000,
530})
531o15 = Create("IntValue",{
532["Name"] = "BlastRadius",
533["Parent"] = o10,
534["Value"] = 8,
535})
536o16 = Create("IntValue",{
537["Name"] = "RocketSpeed",
538["Parent"] = o10,
539["Value"] = 60,
540})
541mas.Parent = workspace
542mas:MakeJoints()
543local mas1 = mas:GetChildren()
544for i=1,#mas1 do
545 mas1[i].Parent = script
546 ypcall(function() mas1[i]:MakeJoints() end)
547end
548mas:Destroy()
549for i=1,#cors do
550coroutine.resume(cors[i])
551end