Advertisement
fusionfriends

fun gun

Mar 15th, 2020
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.27 KB | None | 0 0
  1. -- Services --
  2. local Players = game:GetService("Players")
  3. local TweenService = game:GetService("TweenService")
  4. -- Variables --
  5. local Player = owner
  6. repeat wait() until Player.Character
  7. local Character = Player.Character
  8. local Tool = Instance.new("Tool",Player.Backpack)
  9. local Gun = Instance.new("Part",Tool)
  10. local GunMesh = Instance.new("SpecialMesh",Gun)
  11. local MousePos
  12. IsFiring = false
  13. Intt = 0
  14. Colors = {
  15.     Color3.fromRGB(255,0,0),
  16.     Color3.fromRGB(0,255,0),
  17.     Color3.fromRGB(0,0,255)
  18. }
  19. ObjectList = {
  20.     "ChillHead",
  21.     "Plunger",
  22.     "Bear",
  23.     "Potato",
  24.     "Chicken",
  25.     "MNM",
  26.     "Sans",
  27.     "Frog",
  28.     "Baguette",
  29.     "Duck",
  30.     "Mario",
  31.     "Squidward"
  32. }
  33. -- Mouse Event --
  34. local MouseEvent = Instance.new("RemoteEvent")
  35. MouseEvent.Name = "MouseEvent"
  36. MouseEvent.Parent = NLS([==[
  37. local Mouse = game:GetService("Players").LocalPlayer:GetMouse()
  38. while wait() do
  39.     script.MouseEvent:FireServer(Mouse.Hit.p)
  40. end
  41. ]==],Player.PlayerGui)
  42. MouseEvent.OnServerEvent:Connect(function(Plr,MouseLocation)
  43.     if Plr == Player and MouseLocation then
  44.         MousePos = MouseLocation
  45.     end
  46. end)
  47. -- Functions --
  48. Tool.Equipped:Connect(function()
  49.     local Theme = Instance.new("Sound",Gun)
  50.     Theme.Looped = true
  51.     Theme.Volume = 3
  52.     Theme.SoundId = "rbxassetid://413176884"
  53.     Theme:Play()
  54. end)
  55. Tool.Unequipped:Connect(function()
  56.     for i,v in pairs(Gun:GetChildren()) do
  57.         if v:IsA("Sound") then
  58.             v:Destroy()
  59.         end
  60.     end
  61.     IsFiring = false
  62. end)
  63. Tool.Activated:Connect(function()
  64.     IsFiring = true
  65.     local Sound = Instance.new("Sound",Gun)
  66.     Sound.Name = "FiringSound"
  67.     Sound.Looped = true
  68.     Sound.Volume = 3
  69.     Sound.SoundId = "rbxassetid://2371488630"
  70.     Sound:Play()
  71. end)
  72. Tool.Deactivated:Connect(function()
  73.     IsFiring = false
  74.     if Gun:FindFirstChild("FiringSound") then
  75.         Gun.FiringSound:Destroy()
  76.     end
  77. end)
  78. -- Base Code --
  79. Gun.Size = Vector3.new(.5,.5,.5)
  80. Gun.CanCollide = false
  81. Gun.Massless = true
  82. Gun.Locked = true
  83. Gun.Name = "Handle"
  84. GunMesh.Scale = Vector3.new(0.55,0.55,0.55)
  85. GunMesh.MeshId = "rbxassetid://641905504"
  86. GunMesh.Offset = Vector3.new(0,-0.5,2.7)
  87. Tool.TextureId = "http://www.roblox.com/asset/?id=924922390"
  88. Tool.ToolTip = "bbbbblllppplbbb"
  89. Tool.Grip = CFrame.new(0.146357164, -0.69461441, 3.63811111, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  90. -- Loops --
  91. coroutine.resume(coroutine.create(function()
  92.     while wait(.5) do
  93.         if Intt == #Colors then
  94.             Intt = 0
  95.         end
  96.         Intt = Intt+1
  97.         TweenService:Create(Gun,TweenInfo.new(1),{Color = Colors[Intt]}):Play()
  98.     end
  99. end))
  100. coroutine.resume(coroutine.create(function()
  101.     while wait(.1) do
  102.         if IsFiring then
  103.             local MuzzleFlash = Instance.new("Part",Gun)
  104.             game.Debris:AddItem(MuzzleFlash,.2)
  105.             MuzzleFlash.Name = "MuzzleFlash"
  106.             MuzzleFlash.CanCollide = false
  107.             MuzzleFlash.Material = Enum.Material.Neon
  108.             MuzzleFlash.BrickColor = BrickColor.new("New Yeller")
  109.             MuzzleFlash.Size = Vector3.new(.25,.25,.25)
  110.             MuzzleFlash.CastShadow = false
  111.             local MuzzleFlashWeld = Instance.new("Weld",MuzzleFlash)
  112.             MuzzleFlashWeld.Part0 = MuzzleFlash
  113.             MuzzleFlashWeld.Part1 = Gun
  114.             MuzzleFlashWeld.C0 = CFrame.new(0,0,0)*CFrame.Angles(math.rad(math.random(1,360)),math.rad(math.random(1,360)),math.rad(math.random(1,360)))
  115.             local MuzzleFlashLight = Instance.new("PointLight",MuzzleFlash)
  116.             MuzzleFlashLight.Color = Color3.fromRGB(255,255,0)
  117.             TweenService:Create(MuzzleFlash,TweenInfo.new(.2),{Size = Vector3.new(1,1,1);Color = Color3.fromRGB(213,115,61);Transparency = 1}):Play()
  118.             local ray = Ray.new(Gun.CFrame.p,(MousePos-Gun.CFrame.p).unit*300)
  119.             local IgnoreList = {}
  120.             table.insert(IgnoreList,Gun)
  121.             for i,v in pairs(Gun:GetDescendants()) do
  122.                 table.insert(IgnoreList,v)
  123.             end
  124.             for i,v in pairs(Character:GetDescendants()) do
  125.                 table.insert(IgnoreList,v)
  126.             end
  127.             local TargetPart,Pos = workspace:FindPartOnRayWithIgnoreList(ray,IgnoreList)
  128.             local Distance = (Gun.CFrame.p - Pos).magnitude
  129.             local Beam = Instance.new("Part",Gun)
  130.             Beam.BrickColor = BrickColor.new("New Yeller")
  131.             Beam.Material = Enum.Material.Neon
  132.             Beam.Locked = true
  133.             Beam.Anchored = true
  134.             Beam.CanCollide = false
  135.             Beam.CastShadow = false
  136.             Beam.Size = Vector3.new(0.1,0.1,Distance)
  137.             Beam.CFrame = CFrame.new(Gun.CFrame.p,Pos)*CFrame.new(0,0,-Distance/2)
  138.             game.Debris:AddItem(Beam,.2)
  139.             TweenService:Create(Beam,TweenInfo.new(.2),{Size = Vector3.new(.5,.5,Distance);Transparency = 1;Color = Color3.fromRGB(213,115,61)}):Play()
  140.             local Effect = Instance.new("Part",Gun)
  141.             Effect.Name = "Effect"
  142.             Effect.Material = Enum.Material.Neon
  143.             Effect.Shape = Enum.PartType.Ball
  144.             Effect.BrickColor = BrickColor.new("New Yeller")
  145.             Effect.Size = Vector3.new(.25,.25,.25)
  146.             Effect.CanCollide = false
  147.             Effect.Anchored = true
  148.             Effect.CastShadow = false
  149.             Effect.Position = Pos
  150.             game.Debris:AddItem(Effect,.2)
  151.             TweenService:Create(Effect,TweenInfo.new(.2),{Size = Vector3.new(3,3,3);Transparency = 1;Color = Color3.fromRGB(213,115,61)}):Play()
  152.             if TargetPart and TargetPart:GetMass() < 16 and TargetPart.Name ~= "RandomGunObject" and not TargetPart:IsDescendantOf(Character) then
  153.                 local success,err = pcall(function()
  154.                     TargetPart.Material = Enum.Material.Neon
  155.                     TweenService:Create(TargetPart,TweenInfo.new(.5),{Color = Color3.fromRGB(255,255,255)}):Play()
  156.                     coroutine.resume(coroutine.create(function()
  157.                         wait(.2)
  158.                         local RNG = math.random(1,#ObjectList)
  159.                         local Object = ObjectList[RNG]
  160.                         local Part = Instance.new("Part",workspace)
  161.                         Part.Name = "RandomGunObject"
  162.                         Part.CFrame = TargetPart.CFrame
  163.                         TargetPart:Destroy()
  164.                         local ObjectMesh = Instance.new("SpecialMesh",Part)
  165.                         if Object == "ChillHead" then
  166.                             Part.Size = Vector3.new(1.5,1.75,1.75)
  167.                             ObjectMesh.MeshId = "rbxassetid://4676559534"
  168.                             ObjectMesh.TextureId = "rbxassetid://4676559661"
  169.                         elseif Object == "Plunger" then
  170.                             Part.Size = Vector3.new(1,2.75,1)
  171.                             ObjectMesh.MeshId = "rbxassetid://1839892075"
  172.                             ObjectMesh.TextureId = "rbxassetid://1839892112"
  173.                             ObjectMesh.Scale = Vector3.new(.25,.25,.25)
  174.                         elseif Object == "Bear" then
  175.                             Part.Size = Vector3.new(1,1,1.5)
  176.                             ObjectMesh.MeshId = "http://www.roblox.com/asset/?id=12218321"
  177.                             ObjectMesh.TextureId = "http://www.roblox.com/asset/?id=12218077"
  178.                             ObjectMesh.Scale = Vector3.new(.5,.5,.5)
  179.                         elseif Object == "Potato" then
  180.                             Part.Size = Vector3.new(1,1.25,1)
  181.                             ObjectMesh.MeshId = "rbxassetid://477543051"
  182.                             ObjectMesh.TextureId = "rbxassetid://477543054"
  183.                         elseif Object == "Chicken" then
  184.                             Part.Size = Vector3.new(1,2,2)
  185.                             ObjectMesh.MeshId = "rbxassetid://438720618"
  186.                             ObjectMesh.TextureId = "rbxassetid://438720622"
  187.                             ObjectMesh.Scale = Vector3.new(.25,.25,.25)
  188.                         elseif Object == "MNM" then
  189.                             Part.Size = Vector3.new(2.25,1.5,.75)
  190.                             ObjectMesh.MeshId = "rbxassetid://2840788409"
  191.                             ObjectMesh.TextureId = "rbxassetid://2840788436"
  192.                             ObjectMesh.Scale = Vector3.new(1.5,1.5,1.5)
  193.                         elseif Object == "Sans" then
  194.                             Part.Size = Vector3.new(1.5,1.5,1.5)
  195.                             ObjectMesh.MeshId = "rbxassetid://430073345"
  196.                             ObjectMesh.TextureId = "rbxassetid://430073362"
  197.                             ObjectMesh.Scale = Vector3.new(.75,.75,.75)
  198.                         elseif Object == "Frog" then
  199.                             Part.Size = Vector3.new(1,1.5,.75)
  200.                             ObjectMesh.MeshId = "rbxassetid://890005142"
  201.                             ObjectMesh.TextureId = "rbxassetid://890005160"
  202.                             ObjectMesh.Scale = Vector3.new(3,3,3)
  203.                         elseif Object == "Baguette" then
  204.                             Part.Size = Vector3.new(.5,.25,1.5)
  205.                             ObjectMesh.MeshId = "rbxassetid://2803509055"
  206.                             ObjectMesh.TextureId = "rbxassetid://2803509851"
  207.                         elseif Object == "Duck" then
  208.                             Part.Size = Vector3.new(1,1,1.5)
  209.                             ObjectMesh.MeshId = "rbxassetid://521754610"
  210.                             ObjectMesh.TextureId = "rbxassetid://521754612"
  211.                         elseif Object == "Mario" then
  212.                             Part.Size = Vector3.new(1.25,1.5,1.5)
  213.                             ObjectMesh.MeshId = "rbxassetid://849882710"
  214.                             ObjectMesh.TextureId = "rbxassetid://849882719"
  215.                             ObjectMesh.Scale = Vector3.new(.25,.25,.25)
  216.                         elseif Object == "Squidward" then
  217.                             Part.Size = Vector3.new(1.5,1.75,.75)
  218.                             ObjectMesh.MeshId = "rbxassetid://430074487"
  219.                             ObjectMesh.TextureId = "rbxassetid://430074495"
  220.                         end
  221.                     end))
  222.                 end)
  223.                 if not success then
  224.                     print(err)
  225.                 end
  226.             end
  227.         end
  228.     end
  229. end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement