Advertisement
GabeTheDog

Bartus2009_Bro's Pistol

Jun 9th, 2018
721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.51 KB | None | 0 0
  1. --Made By Bartus2009_Bro/GabeTheDog
  2.  
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. RemoteEvent1 = Instance.new("RemoteEvent")
  21. RemoteEvent2 = Instance.new("RemoteEvent")
  22. LocalScript3 = Instance.new("LocalScript")
  23. Script4 = Instance.new("Script")
  24. Configuration5 = Instance.new("Configuration")
  25. NumberValue6 = Instance.new("NumberValue")
  26. NumberValue7 = Instance.new("NumberValue")
  27. NumberValue8 = Instance.new("NumberValue")
  28. NumberValue9 = Instance.new("NumberValue")
  29. NumberValue10 = Instance.new("NumberValue")
  30. NumberValue11 = Instance.new("NumberValue")
  31. NumberValue12 = Instance.new("NumberValue")
  32. Sound13 = Instance.new("Sound")
  33. Sound14 = Instance.new("Sound")
  34. Part15 = Instance.new("Part")
  35. BillboardGui16 = Instance.new("BillboardGui")
  36. ImageLabel17 = Instance.new("ImageLabel")
  37. CFrameValue18 = Instance.new("CFrameValue")
  38. Weld19 = Instance.new("Weld")
  39. RemoteEvent20 = Instance.new("RemoteEvent")
  40. Tool0.Name = "Pistol"
  41. Tool0.Parent = mas
  42. Tool0.TextureId = "rbxassetid://131768786"
  43. Tool0.GripForward = Vector3.new(0.997598529, -0, -0.0692615658)
  44. Tool0.GripPos = Vector3.new(-0.792874813, -0.37231636, 0.112739533)
  45. Tool0.GripRight = Vector3.new(0.0692615658, 0, 0.997598529)
  46. Tool0.ToolTip = "Activate the Trigger Happy special by pressing E or using the mobile button!"
  47. RemoteEvent1.Name = "Hit"
  48. RemoteEvent1.Parent = Tool0
  49. RemoteEvent2.Name = "Fire"
  50. RemoteEvent2.Parent = Tool0
  51. LocalScript3.Name = "Client"
  52. LocalScript3.Parent = Tool0
  53. table.insert(cors,sandbox(LocalScript3,function()
  54. --//Variables\\--
  55. local tool = script.Parent
  56. local handle = tool:WaitForChild("Handle")
  57.  
  58. local contextActionService = game:GetService("ContextActionService")
  59.  
  60. local player = game.Players.LocalPlayer
  61. local mouse = player:GetMouse()
  62. local character = player.Character or player.CharacterAdded:Wait()
  63.  
  64. local enabled = true
  65. local specialDB = true
  66.  
  67. local cursorId = "http://www.roblox.com/asset/?id=251497633"
  68. local hitId = "http://www.roblox.com/asset/?id=70785856"
  69.  
  70. local configs = tool:WaitForChild("Configurations")
  71. local fireRate = configs:FindFirstChild("FireRate")
  72. local specialRechargeTime = configs:FindFirstChild("SpecialRechargeTime")
  73.  
  74. local fire = tool:WaitForChild("Fire")
  75. local activateSpecial = tool:WaitForChild("ActivateSpecial")
  76. local hit = tool:WaitForChild("Hit")
  77.  
  78. --//Custom Functions\\--
  79. function activate()
  80. if specialDB then
  81. specialDB = false
  82. activateSpecial:FireServer()
  83. else
  84. end
  85. end
  86.  
  87. --//Tool Function\\--
  88. tool.Equipped:Connect(function()
  89. contextActionService:BindAction("ActivateSpecial", activate, true, Enum.KeyCode.E)
  90. contextActionService:SetImage("ActivateSpecial", tool.TextureId)
  91. contextActionService:SetPosition("ActivateSpecial", UDim2.new(0.72, -25, 0.20, -25))
  92. mouse.Icon = cursorId
  93. end)
  94.  
  95. tool.Unequipped:Connect(function()
  96. contextActionService:UnbindAction("ActivateSpecial")
  97. mouse.Icon = ""
  98. end)
  99.  
  100. tool.Activated:Connect(function()
  101. if not enabled then return end
  102.  
  103. enabled = false
  104. fire:FireServer(mouse.Hit)
  105. wait(fireRate.Value)
  106. enabled = true
  107. end)
  108.  
  109. hit.OnClientEvent:Connect(function()
  110. mouse.Icon = hitId
  111. handle.Hitmark:Play()
  112. wait(0.075)
  113. mouse.Icon = cursorId
  114. end)
  115.  
  116. activateSpecial.OnClientEvent:Connect(function()
  117.  
  118. for i = specialRechargeTime.Value, 0, -1 do
  119. wait(1)
  120. specialDB = false
  121. print("Recharging: "..i)
  122. end
  123.  
  124. specialDB = true
  125. end)
  126. end))
  127. Script4.Name = "Server"
  128. Script4.Parent = Tool0
  129. table.insert(cors,sandbox(Script4,function()
  130. --//Variables\\--
  131. local tool = script.Parent
  132. local handle = tool:WaitForChild("Handle")
  133. local muzzle = tool:WaitForChild("Muzzle")
  134. local muzzleFlash = muzzle:WaitForChild("MuzzleFlash")
  135. local muzzleEffect = muzzleFlash:WaitForChild("MuzzleEffect")
  136.  
  137. local configs = tool:WaitForChild("Configurations")
  138. local fireRate = configs:FindFirstChild("FireRate")
  139. local maxDamage = configs:FindFirstChild("MaxDamage")
  140. local minDamage = configs:FindFirstChild("MinDamage")
  141. local velocity = configs:FindFirstChild("Velocity")
  142. local accuracy = configs:FindFirstChild("Accuracy")
  143. local specialDuration = configs:FindFirstChild("SpecialDuration")
  144. local specialRechargeTime = configs:FindFirstChild("SpecialRechargeTime")
  145.  
  146. local showDamageText = true
  147.  
  148. local debris = game:GetService("Debris")
  149.  
  150. local fire = tool:WaitForChild("Fire")
  151. local activateSpecial = tool:WaitForChild("ActivateSpecial")
  152. local hit = tool:WaitForChild("Hit")
  153.  
  154. --//Custom Functions\\--
  155. function TagHumanoid(humanoid, player)
  156. local Creator_Tag = Instance.new("ObjectValue")
  157. Creator_Tag.Name = "creator"
  158. Creator_Tag.Value = player
  159. debris:AddItem(Creator_Tag, 0.3)
  160. Creator_Tag.Parent = humanoid
  161. end
  162.  
  163. function UntagHumanoid(humanoid)
  164. for i, v in pairs(humanoid:GetChildren()) do
  165. if v:IsA("ObjectValue") and v.Name == "creator" then
  166. v:Destroy()
  167. end
  168. end
  169. end
  170.  
  171. function TextEffects(element, floatAmount, direction, style, duration)
  172. element:TweenPosition(UDim2.new(0, math.random(-40, 40), 0, -floatAmount), direction, style, duration)
  173. wait(0.5)
  174.  
  175. for i = 1, 60 do
  176. element.TextTransparency = element.TextTransparency + 1/60
  177. element.TextStrokeTransparency = element.TextStrokeTransparency + 1/60
  178. wait(1/60)
  179. end
  180.  
  181. element.TextTransparency = element.TextTransparency + 1
  182. element.TextStrokeTransparency = element.TextStrokeTransparency + 1
  183. element.Parent:Destroy()
  184. end
  185.  
  186. function DynamicText(damage, criticalPoint, humanoid)
  187. local bill = Instance.new("BillboardGui", humanoid.Parent.Head)
  188. bill.Size = UDim2.new(0, 50, 0, 100)
  189. local part = Instance.new("TextLabel", bill)
  190. bill.AlwaysOnTop = true
  191. part.TextColor3 = Color3.fromRGB(255, 0, 0)
  192. part.Text = damage
  193. part.Font = Enum.Font.SourceSans
  194. part.TextStrokeTransparency = 0
  195. part.Size = UDim2.new(1, 0, 1, 0)
  196. part.Position = UDim2.new(0, 0, 0, 0)
  197. part.BackgroundTransparency = 1
  198. bill.Adornee = bill.Parent
  199.  
  200. if damage < criticalPoint then
  201. part.TextSize = 28
  202. part.TextColor3 = Color3.new(1, 0, 0)
  203. elseif damage >= criticalPoint then
  204. part.TextSize = 32
  205. part.TextColor3 = Color3.new(1, 1, 0)
  206. end
  207.  
  208. spawn(function()
  209. TextEffects(part, 85, Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.75)
  210. end)
  211. end
  212.  
  213. function DamageAndTagHumanoid(player, humanoid, damage)
  214. hit:FireClient(player)
  215. UntagHumanoid(handle)
  216. humanoid:TakeDamage(damage) TagHumanoid(humanoid, player)
  217. end
  218.  
  219. --//Remote Functions\\--
  220. fire.OnServerEvent:Connect(function(player, mouseHit)
  221. local character = player.Character
  222. local humanoid = character:FindFirstChild("Humanoid")
  223. local weaponAccuracy = Vector3.new(math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2))
  224.  
  225. if humanoid and humanoid ~= 0 then
  226. local projectile = Instance.new("Part", workspace)
  227.  
  228. local trail = Instance.new("Trail", projectile)
  229. trail.FaceCamera = true
  230. trail.Lifetime = 0.3
  231. trail.MinLength = 0.15
  232. trail.LightEmission = 0.25
  233.  
  234. local attachment0 = Instance.new("Attachment", projectile)
  235. attachment0.Position = Vector3.new(0.35, 0, 0)
  236. attachment0.Name = "Attachment1"
  237. local attachment1 = Instance.new("Attachment", projectile)
  238. attachment1.Position = Vector3.new(-0.35, 0, 0)
  239. attachment1.Name = "Attachment1"
  240.  
  241. trail.Attachment0 = attachment0
  242. trail.Attachment1 = attachment1
  243.  
  244. projectile.Name = "Bullet"
  245. projectile.BrickColor = BrickColor.new("Smoky gray")
  246. projectile.Shape = "Ball"
  247. projectile.Material = Enum.Material.Metal
  248. projectile.TopSurface = 0
  249. projectile.BottomSurface = 0
  250. projectile.Size = Vector3.new(1, 1, 1)
  251. projectile.Transparency = 1
  252. projectile.CFrame = CFrame.new(muzzle.CFrame.p, mouseHit.p)
  253. projectile.CanCollide = false
  254.  
  255. local transparencyPoints = {}
  256. local startColor = Color3.new(255, 255, 0)
  257. local endColor = Color3.new(213, 115, 61)
  258.  
  259. table.insert(transparencyPoints, NumberSequenceKeypoint.new(0, 1))
  260. table.insert(transparencyPoints, NumberSequenceKeypoint.new(0.25, 0))
  261. table.insert(transparencyPoints, NumberSequenceKeypoint.new(1, 1))
  262.  
  263. local determinedTransparency = NumberSequence.new(transparencyPoints)
  264. local determinedColors = ColorSequence.new(startColor, endColor)
  265.  
  266. trail.Transparency = determinedTransparency
  267. trail.Color = determinedColors
  268.  
  269. local bodyVelocity = Instance.new("BodyVelocity", projectile)
  270. bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9)
  271. bodyVelocity.Velocity = (mouseHit.lookVector * velocity.Value) + weaponAccuracy
  272.  
  273. debris:AddItem(projectile, 20)
  274.  
  275. projectile.Touched:Connect(function(hit)
  276. local eHumanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
  277. local damage = math.random(minDamage.Value, maxDamage.Value)
  278. if not eHumanoid and not hit.Anchored and not hit:IsDescendantOf(character) then
  279.  
  280. projectile:Destroy()
  281. elseif eHumanoid and eHumanoid ~= humanoid and eHumanoid.Health > 0 and hit ~= projectile then
  282.  
  283. if hit.Name == "Head" or hit:IsA("Hat") then
  284. damage = damage * 1.5
  285. end
  286.  
  287. local criticalPoint = maxDamage.Value
  288. DamageAndTagHumanoid(player, eHumanoid, damage)
  289.  
  290. if showDamageText then
  291. DynamicText(damage, criticalPoint, eHumanoid)
  292. else
  293. end
  294.  
  295. projectile:Destroy()
  296. elseif hit.CanCollide == true and not hit:IsDescendantOf(player.Character) and hit.Anchored == true then
  297.  
  298. projectile:Destroy()
  299. end
  300. end)
  301.  
  302. handle.Fire:Play()
  303. muzzleEffect.Visible = true
  304. muzzleEffect.Rotation = math.random(-360, 360)
  305.  
  306. delay(0.1, function()
  307. muzzleEffect.Visible = false
  308. end)
  309.  
  310. end
  311. end)
  312.  
  313. activateSpecial.OnServerEvent:Connect(function(player)
  314. accuracy.Value, fireRate.Value = accuracy.Value / 2, fireRate.Value / 2
  315. minDamage.Value, maxDamage.Value = minDamage.Value / 2, maxDamage.Value / 2
  316.  
  317. spawn(function()
  318. local chargeSound = Instance.new("Sound", player.PlayerGui)
  319. chargeSound.Name = "ChargeSound"
  320. chargeSound.SoundId = "rbxassetid://163619849"
  321. chargeSound:Play()
  322.  
  323. chargeSound.Ended:Connect(function() chargeSound:Destroy() end)
  324.  
  325. local sparkles = Instance.new("Sparkles", handle)
  326. sparkles.SparkleColor = Color3.fromRGB(255, 236, 21)
  327.  
  328. local activatedGui = Instance.new("ScreenGui", player.PlayerGui)
  329. activatedGui.Name = "SpecialActivated"
  330. local textLabel = Instance.new("TextLabel", activatedGui)
  331. textLabel.TextColor3 = Color3.fromRGB(0, 180, 30)
  332. textLabel.Text = "Trigger Happy activated!"
  333. textLabel.Font = Enum.Font.SourceSans
  334. textLabel.TextScaled = true
  335. textLabel.TextStrokeTransparency = 0
  336. textLabel.Size = UDim2.new(0, 300, 0, 50)
  337. textLabel.Position = UDim2.new(2.5, 0, 0.15, -10)
  338. textLabel.BackgroundTransparency = 1
  339. textLabel:TweenPosition(UDim2.new(0.5, -(textLabel.Size.X.Offset / 2), 0.1, -10), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)
  340.  
  341. debris:AddItem(sparkles, specialDuration.Value)
  342. debris:AddItem(chargeSound, 3)
  343.  
  344. wait(3)
  345. TextEffects(textLabel, 200, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1)
  346. end)
  347.  
  348. for i = specialDuration.Value, 0, -1 do
  349. wait(1)
  350. print("Special activated: "..i)
  351. end
  352.  
  353. accuracy.Value, fireRate.Value = accuracy.Value * 2, fireRate.Value * 2
  354. minDamage.Value, maxDamage.Value = minDamage.Value * 2, maxDamage.Value * 2
  355. activateSpecial:FireClient(player)
  356. end)
  357. end))
  358. Configuration5.Name = "Configurations"
  359. Configuration5.Parent = Tool0
  360. NumberValue6.Name = "FireRate"
  361. NumberValue6.Parent = Configuration5
  362. NumberValue6.Value = 0.175
  363. NumberValue7.Name = "MinDamage"
  364. NumberValue7.Parent = Configuration5
  365. NumberValue7.Value = 14
  366. NumberValue8.Name = "MaxDamage"
  367. NumberValue8.Parent = Configuration5
  368. NumberValue8.Value = 17
  369. NumberValue9.Name = "Velocity"
  370. NumberValue9.Parent = Configuration5
  371. NumberValue9.Value = 625
  372. NumberValue10.Name = "Accuracy"
  373. NumberValue10.Parent = Configuration5
  374. NumberValue10.Value = 9
  375. NumberValue11.Name = "SpecialDuration"
  376. NumberValue11.Parent = Configuration5
  377. NumberValue11.Value = 15
  378. NumberValue12.Name = "SpecialRechargeTime"
  379. NumberValue12.Parent = Configuration5
  380. NumberValue12.Value = 60
  381. Sound13.Name = "Fire"
  382. Sound13.Parent = mas
  383. Sound13.SoundId = "rbxassetid://330704232"
  384. Sound13.Volume = 3
  385. Sound14.Name = "Hitmark"
  386. Sound14.Parent = mas
  387. Sound14.SoundId = "rbxassetid://160432334"
  388. Sound14.Volume = 10
  389. Part15.Name = "Muzzle"
  390. Part15.Parent = Tool0
  391. Part15.Transparency = 1
  392. Part15.Rotation = Vector3.new(-1.01999998, 86.0299988, 0)
  393. Part15.CanCollide = false
  394. Part15.Size = Vector3.new(0.100000001, 0.100000001, 0.100000001)
  395. Part15.CFrame = CFrame.new(-130.112228, 19.4021873, 39.8008919, 0.0692615658, 3.11348858e-09, 0.997598529, -0.0177569855, 0.999841571, 0.00123284035, -0.997440577, -0.0177996811, 0.0692505985)
  396. Part15.BottomSurface = Enum.SurfaceType.Smooth
  397. Part15.TopSurface = Enum.SurfaceType.Smooth
  398. Part15.Position = Vector3.new(-130.112228, 19.4021873, 39.8008919)
  399. Part15.Orientation = Vector3.new(-0.0700000003, 86.0299988, -1.01999998)
  400. BillboardGui16.Name = "MuzzleFlash"
  401. BillboardGui16.Parent = Part15
  402. BillboardGui16.Size = UDim2.new(0, 150, 0, 150)
  403. BillboardGui16.Active = true
  404. BillboardGui16.Adornee = Part15
  405. ImageLabel17.Name = "MuzzleEffect"
  406. ImageLabel17.Parent = BillboardGui16
  407. ImageLabel17.Transparency = 1
  408. ImageLabel17.Size = UDim2.new(1, 0, 1, 0)
  409. ImageLabel17.Visible = false
  410. ImageLabel17.BackgroundColor3 = Color3.new(1, 1, 1)
  411. ImageLabel17.BackgroundTransparency = 1
  412. ImageLabel17.Image = "rbxassetid://192664810"
  413. CFrameValue18.Name = "qRelativeCFrameWeldValue"
  414. CFrameValue18.Parent = Part15
  415. CFrameValue18.Value = CFrame.new(-1.15686202, -0.59147644, -0.005217731, 1.00000012, -2.42143869e-08, -6.51925802e-09, -2.42143869e-08, 1, 4.80213203e-09, -6.51925802e-09, 4.80213203e-09, 1)
  416. Weld19.Name = "qCFrameWeldThingy"
  417. Weld19.Parent = Part15
  418. Weld19.C1 = CFrame.new(-1.15686202, -0.59147644, -0.005217731, 1.00000012, -2.42143869e-08, -6.51925802e-09, -2.42143869e-08, 1, 4.80213203e-09, -6.51925802e-09, 4.80213203e-09, 1)
  419. Weld19.Part0 = nil
  420. Weld19.Part1 = Part15
  421. RemoteEvent20.Name = "ActivateSpecial"
  422. RemoteEvent20.Parent = Tool0
  423. for i,v in pairs(mas:GetChildren()) do
  424. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  425. pcall(function() v:MakeJoints() end)
  426. end
  427. mas:Destroy()
  428. for i,v in pairs(cors) do
  429. spawn(function()
  430. pcall(v)
  431. end)
  432. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement