Advertisement
Josemmoya

Untitled

Jul 17th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.43 KB | None | 0 0
  1. -- This script has been converted to FE by iPxter
  2.  
  3.  
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  6. do
  7. print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  8. script.Parent = Player.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent and t.Function then
  34. t.Function(...)
  35. end
  36. end
  37. m.TrigEvent = te
  38. UIS.TrigEvent = te
  39.  
  40. Event.OnServerEvent:Connect(function(plr,io)
  41. if plr~=Player then return end
  42. if io.isMouse then
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. else
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. for _,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59. end
  60. end)
  61. Event.Parent = NLS([==[
  62. local Player = game:GetService("Players").LocalPlayer
  63. local Event = script:WaitForChild("UserInput_Event")
  64.  
  65. local UIS = game:GetService("UserInputService")
  66. local input = function(io,a)
  67. if a then return end
  68. --Since InputObject is a client-side instance, we create and pass table instead
  69. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  70. end
  71. UIS.InputBegan:Connect(input)
  72. UIS.InputEnded:Connect(input)
  73.  
  74. local Mouse = Player:GetMouse()
  75. local h,t
  76. --Give the server mouse data 30 times every second, but only if the values changed
  77. --If player is not moving their mouse, client won't fire events
  78. while wait(1/30) do
  79. if h~=Mouse.Hit or t~=Mouse.Target then
  80. h,t=Mouse.Hit,Mouse.Target
  81. Event:FireServer({isMouse=true,Target=t,Hit=h})
  82. end
  83. end]==],Player.Character)
  84. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  85. end
  86.  
  87. --[[
  88. Objects Skipped: 1
  89. UnionOperation: 1
  90. --]]
  91. player = owner
  92. character = owner.Character
  93.  
  94. function CreateObject(b,c)local d=Instance.new(b)
  95. for e,f in pairs(c)do d[f[1]]=f[2]end;return d end
  96. gold=CreateObject("Tool",{{"TextureId","rbxassetid://2530942954"},{"Name","gold"},{"ToolTip","YEETUS"},{"Parent",player.Backpack}})
  97. FakeHandle=CreateObject("Part",{{"CanCollide",false},{"Shape",2},{"Size",Vector3.new(0.29,0.25,0.48)},{"BottomSurface",0},{"Orientation",Vector3.new(0,
  98. -90,0)},{"Material",1568},{"Name","FakeHandle"},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  99. -88.065,0.215,195.145)*CFrame.Angles(0,-1.571,0)}})
  100. fire=CreateObject("Sound",{{"PlaybackSpeed",0.7},{"Name","Fire"},{"SoundId","rbxassetid://1590181673"},{"Parent",FakeHandle}})
  101. reload=CreateObject("Sound",{{"PlaybackSpeed",0.7},{"Name","Reload"},{"SoundId","rbxassetid://138084889"},{"Parent",FakeHandle}})
  102. pointlight=CreateObject("PointLight",{{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Range",6},{"Parent",FakeHandle}})
  103. part=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.36,0.05,0.28)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  104. -88.06,0.195,195.14)}})
  105. part_2=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(1.3,0.14,0.73)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  106. -87.07,0.23,197.005)}})
  107. part_3=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.23,0.14,0.06)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  108. -87.605,0.23,196.18)}})
  109. part_4=CreateObject("Part",{{"CanCollide",false},{"Shape",2},{"Size",Vector3.new(1.1,0.18,0.23)},{"Orientation",Vector3.new(0,
  110. -90,0)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  111. -88.06,0.21,195.77)*CFrame.Angles(0,-1.571,0)}})
  112. part_5=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.13,0.1,0.52)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  113. -87.905,0.23,196.12)}})
  114. part_6=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.46,0.14,1.09)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  115. -87.95,0.23,196.865)}})
  116. part_7=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.46,0.14,0.1)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(24)},{"TopSurface",0},{"Color",Color3.new(0.960784,0.803922,0.188235)},{"Parent",gold},{"CFrame",CFrame.new(
  117. -87.95,0.23,197.46)*CFrame.Angles(0,0,0)}})
  118. part_8=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.24,0.14,0.06)},{"Orientation",Vector3.new(0,31.41,0)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  119. -87.398,0.23,196.124)*CFrame.Angles(0,0.548,0)}})
  120. part_9=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(0.13,0.1,0.42)},{"Material",1568},{"BottomSurface",0},{"BrickColor",BrickColor.new(333)},{"TopSurface",0},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"Parent",gold},{"CFrame",CFrame.new(
  121. -87.775,0.23,196.17)}})
  122. handle=CreateObject("Part",{{"CanCollide",false},{"Size",Vector3.new(1.3,0.14,0.73)},{"BottomSurface",0},{"Orientation",Vector3.new(0,0,90.29)},{"Material",1568},{"Name","Handle"},{"Transparency",1},{"BrickColor",BrickColor.new(333)},{"Color",Color3.new(0.937255,0.721569,0.219608)},{"TopSurface",0},{"Parent",gold},{"CFrame",CFrame.new(
  123. -87.07,0.23,197.005)*CFrame.Angles(0,0,1.576)}})
  124.  
  125. --functions lol fuck
  126. local H = gold:GetChildren()
  127. for i = 1, #H do
  128. local P0 = gold.Handle
  129. local P = H[i]
  130. if P.ClassName == "Part" then
  131. local W = Instance.new("Weld")
  132. W.Part0 = P0
  133. W.Part1 = P
  134. W.C0 = P0.CFrame:inverse()
  135. W.C1 = P.CFrame:inverse()
  136. W.Parent = script.Parent
  137. W.Name = "UEWeld"
  138. end
  139. end
  140.  
  141. local Can = true
  142. function oe(m)
  143. if Can == false then return end
  144. Can = false
  145. local H = gold:GetChildren()
  146. for i = 1, #H do
  147. local P0 = gold.Handle
  148. local P = H[i]
  149. if P.Name ~= "Bullet" then
  150. if P.ClassName == "Part" then
  151. local W = Instance.new("Weld")
  152. W.Part0 = P0
  153. W.Part1 = P
  154. W.C0 = P0.CFrame:inverse()
  155. W.C1 = P.CFrame:inverse()
  156. W.Parent = script.Parent
  157. W.Name = "EWeld"
  158. end
  159.  
  160. local H = script.Parent:GetChildren()
  161. for i = 1, #H do
  162. if P.ClassName == "Weld" and P.Name == "UEWeld" then P:Destroy() end
  163. if P.ClassName == "Part" then P.Anchored = false end
  164. end
  165.  
  166. Can = true
  167. end
  168. end
  169. end
  170. gold.Equipped:connect(oe)
  171.  
  172. function oe()
  173. if Can == false then return end
  174. Can = false
  175. local H = gold:GetChildren()
  176. for i = 1, #H do
  177. local P0 = gold.Handle
  178. local P = H[i]
  179. if P.Name ~= "Bullet" then
  180. if P.ClassName == "Part" then
  181. local W = Instance.new("Weld")
  182. W.Part0 = P0
  183. W.Part1 = P
  184. W.C0 = P0.CFrame:inverse()
  185. W.C1 = P.CFrame:inverse()
  186. W.Parent = script.Parent
  187. W.Name = "UEWeld"
  188. end
  189.  
  190. for i = 1, #H do
  191. if P.ClassName == "Weld" and P.Name == "EWeld" then P:Destroy() end
  192. if P.ClassName == "Part" then P.Anchored = true end
  193. end
  194.  
  195. Can = true
  196. end
  197. end
  198. end
  199. gold.Unequipped:connect(oe)
  200. local Tool = gold;
  201.  
  202. enabled = true
  203. function onButton1Down(mouse)
  204. if not enabled then
  205. return
  206. end
  207.  
  208. enabled = false
  209. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  210.  
  211. wait(.5)
  212. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  213. enabled = true
  214.  
  215. end
  216.  
  217. function onEquippedLocal(mouse)
  218.  
  219. if mouse == nil then
  220. print("Mouse not found")
  221. return
  222. end
  223.  
  224. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  225. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  226.  
  227. local g = gold:GetChildren()
  228. for i=1, #g do
  229. if g[i].className == "Part" then
  230. g[i].CanCollide = false
  231. end
  232. end
  233. end
  234.  
  235.  
  236. Tool.Equipped:connect(onEquippedLocal)
  237.  
  238. function onUnequippedLocal(mouse)
  239. local g = gold:GetChildren()
  240. for i=1, #g do
  241. if g[i].className == "Part" then
  242. g[i].CanCollide = true
  243. end
  244. end
  245. end
  246.  
  247. Tool.Unequipped:connect(onUnequippedLocal)
  248. -----------------
  249. --| Constants |--
  250. -----------------
  251.  
  252. local SHOT_SPEED = 100
  253. local SHOT_TIME = 1
  254.  
  255. local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)
  256.  
  257. -----------------
  258. --| Variables |--
  259. -----------------
  260.  
  261. local PlayersService = Game:GetService('Players')
  262. local DebrisService = Game:GetService('Debris')
  263.  
  264. local Tool = gold
  265. local Handle = Tool:WaitForChild('Handle')
  266.  
  267. local FireSound = Handle:WaitForChild('Fire')
  268. local ReloadSound = Handle:WaitForChild('Reload')
  269. --local HitFadeSound = Handle:WaitForChild('HitFade')
  270.  
  271. local PointLight = Handle:WaitForChild('PointLight')
  272.  
  273. local Character = nil
  274. local Humanoid = nil
  275. local Player = nil
  276.  
  277. local BaseShot = nil
  278.  
  279. -----------------
  280. --| Functions |--
  281. -----------------
  282.  
  283. -- Returns a character ancestor and its Humanoid, or nil
  284. local function FindCharacterAncestor(subject)
  285. if subject and subject ~= Workspace then
  286. local humanoid = subject:FindFirstChild('Humanoid')
  287. if humanoid then
  288. return subject, humanoid
  289. else
  290. return FindCharacterAncestor(subject.Parent)
  291. end
  292. end
  293. return nil
  294. end
  295.  
  296. -- Removes any old creator tags and applies new ones to the specified target
  297. local function ApplyTags(target)
  298. while target:FindFirstChild('creator') do
  299. target.creator:Destroy()
  300. end
  301.  
  302. local creatorTag = Instance.new('ObjectValue')
  303. creatorTag.Value = Player
  304. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  305.  
  306. local iconTag = Instance.new('StringValue')
  307. iconTag.Value = Tool.TextureId
  308. iconTag.Name = 'icon'
  309.  
  310. iconTag.Parent = creatorTag
  311. creatorTag.Parent = target
  312. DebrisService:AddItem(creatorTag, 4)
  313. end
  314.  
  315. -- Returns all objects under instance with Transparency
  316. local function GetTransparentsRecursive(instance, partsTable)
  317. local partsTable = partsTable or {}
  318. for _, child in pairs(instance:GetChildren()) do
  319. if child:IsA('BasePart') or child:IsA('Decal') then
  320. table.insert(partsTable, child)
  321. end
  322. GetTransparentsRecursive(child, partsTable)
  323. end
  324. return partsTable
  325. end
  326.  
  327. local function SelectionBoxify(instance)
  328. local selectionBox = Instance.new('SelectionBox')
  329. selectionBox.Adornee = instance
  330. selectionBox.Color = BrickColor.new('Gold')
  331. selectionBox.Parent = instance
  332. return selectionBox
  333. end
  334.  
  335. local function Light(instance)
  336. local light = PointLight:Clone()
  337. light.Range = light.Range + 2
  338. light.Parent = instance
  339. end
  340.  
  341. local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
  342. repeat
  343. local lastObject = nil
  344. for _, object in pairs(objectsWithTransparency) do
  345. object.Transparency = object.Transparency + fadeIncrement
  346. lastObject = object
  347. end
  348. wait()
  349. until lastObject.Transparency >= 1 or not lastObject
  350. end
  351.  
  352. local function Dematerialize(character, humanoid, firstPart)
  353. humanoid.WalkSpeed = 0
  354.  
  355. local parts = {}
  356. for _, child in pairs(character:GetChildren()) do
  357. if child:IsA('BasePart') then
  358. child.Anchored = true
  359. table.insert(parts, child)
  360. elseif child:IsA('LocalScript') or child:IsA('Script') then
  361. child:Destroy()
  362. end
  363. end
  364.  
  365. local selectionBoxes = {}
  366.  
  367. local firstSelectionBox = SelectionBoxify(firstPart)
  368. Light(firstPart)
  369. wait(0.05)
  370.  
  371. for _, part in pairs(parts) do
  372. if part ~= firstPart then
  373. table.insert(selectionBoxes, SelectionBoxify(part))
  374. Light(part)
  375. end
  376. end
  377.  
  378. local objectsWithTransparency = GetTransparentsRecursive(character)
  379. FadeOutObjects(objectsWithTransparency, 0.1)
  380.  
  381. wait(0.5)
  382.  
  383. humanoid.Health = 0
  384. DebrisService:AddItem(character, 2)
  385.  
  386. local fadeIncrement = 0.05
  387. Delay(0.2, function()
  388. FadeOutObjects({firstSelectionBox}, fadeIncrement)
  389. if character then
  390. character:Destroy()
  391. end
  392. end)
  393. FadeOutObjects(selectionBoxes, fadeIncrement)
  394. end
  395.  
  396. local function OnTouched(shot, otherPart)
  397. local character, humanoid = FindCharacterAncestor(otherPart)
  398. if character and humanoid and character ~= Character then
  399. ApplyTags(humanoid)
  400. if shot then
  401. --local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
  402. --if hitFadeSound then
  403. --hitFadeSound.Parent = humanoid.Torso
  404. --hitFadeSound:Play()
  405. end
  406. shot:Destroy()
  407. end
  408. Dematerialize(character, humanoid, otherPart)
  409. end
  410.  
  411. local function OnEquipped()
  412. Character = Tool.Parent
  413. Humanoid = Character:WaitForChild('Humanoid')
  414. Player = PlayersService:GetPlayerFromCharacter(Character)
  415. plr = owner
  416.  
  417. hum = plr.Character.HumanoidRootPart
  418.  
  419. mouse.KeyDown:connect(function(key)
  420.  
  421. if key == "q" then
  422.  
  423. if mouse.Target then
  424.  
  425. hum.CFrame = CFrame.new(mouse.Hit.x, mouse.Hit.y + 5, mouse.Hit.z)
  426.  
  427. end
  428.  
  429. end
  430. end)
  431. end
  432.  
  433. local function OnActivated()
  434. if Tool.Enabled and Humanoid.Health > 0 then
  435. Tool.Enabled = false
  436.  
  437. FireSound:Play()
  438.  
  439. local handleCFrame = Handle.CFrame
  440. local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
  441. local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
  442.  
  443. local laserShotClone = BaseShot:Clone()
  444. laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
  445. local bodyVelocity = Instance.new('BodyVelocity')
  446. bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
  447. bodyVelocity.Parent = laserShotClone
  448. laserShotClone.Touched:connect(function(otherPart)
  449. OnTouched(laserShotClone, otherPart)
  450. end)
  451. DebrisService:AddItem(laserShotClone, SHOT_TIME)
  452. laserShotClone.Parent = Tool
  453.  
  454. wait(0.6) -- FireSound length
  455.  
  456. ReloadSound:Play()
  457. wait(0.75) -- ReloadSound length
  458.  
  459. Tool.Enabled = true
  460. end
  461. end
  462.  
  463. local function OnUnequipped()
  464.  
  465. end
  466.  
  467. --------------------
  468. --| Script Logic |--
  469. --------------------
  470.  
  471. BaseShot = Instance.new('Part')
  472. BaseShot.Name = 'Effect'
  473. BaseShot.FormFactor = Enum.FormFactor.Custom
  474. BaseShot.Size = Vector3.new(0.2, 0.2, 3)
  475. BaseShot.CanCollide = false
  476. BaseShot.BrickColor = BrickColor.new('Gold')
  477. SelectionBoxify(BaseShot)
  478. Light(BaseShot)
  479. HitFadeSound:Clone().Parent = BaseShot
  480.  
  481. Tool.Equipped:connect(OnEquipped)
  482. Tool.Unequipped:connect(OnUnequipped)
  483. Tool.Activated:connect(OnActivated)
  484. function killer()
  485. if Mouse.Target.Parent ~= char and Mouse.Target.Parent.Parent ~= char and Mouse.Target.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
  486. FireSound:Play()
  487. Mouse.Target.Parent:BreakJoints()
  488. wait(1)
  489. ReloadSound:Play()
  490. end
  491. end
  492. ----------------------------------
  493. Mouse.KeyDown:connect(function(key)
  494. if key == 'v' then
  495. killer()
  496. end
  497. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement