Advertisement
firebudgy

Untitled

Jun 3rd, 2018
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  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. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Animation5 = Instance.new("Animation")
  25. Configuration6 = Instance.new("Configuration")
  26. NumberValue7 = Instance.new("NumberValue")
  27. NumberValue8 = Instance.new("NumberValue")
  28. NumberValue9 = Instance.new("NumberValue")
  29. BoolValue10 = Instance.new("BoolValue")
  30. NumberValue11 = Instance.new("NumberValue")
  31. LocalScript12 = Instance.new("LocalScript")
  32. RemoteEvent13 = Instance.new("RemoteEvent")
  33. Script14 = Instance.new("Script")
  34. Tool0.Name = "Grenade"
  35. Tool0.Parent = mas
  36. Tool0.TextureId = "http://www.roblox.com/asset/?id=200845119"
  37. Tool0.GripForward = Vector3.new(0.447173357, -0.0044717337, -0.894436121)
  38. Tool0.GripPos = Vector3.new(0, 0, 0.200000003)
  39. Tool0.GripRight = Vector3.new(0.894391418, -0.00894391444, 0.447195709)
  40. Tool0.GripUp = Vector3.new(0.00999950059, 0.999949992, 0)
  41. Tool0.ToolTip = "KABOOM"
  42. Part1.Name = "Handle"
  43. Part1.Parent = Tool0
  44. Part1.BrickColor = BrickColor.new("Earth green")
  45. Part1.Rotation = Vector3.new(0, 90, 0)
  46. Part1.CanCollide = false
  47. Part1.Locked = true
  48. Part1.FormFactor = Enum.FormFactor.Custom
  49. Part1.Size = Vector3.new(0.800000131, 0.920000255, 0.799998164)
  50. Part1.CFrame = CFrame.new(-43.3999977, 0.460000128, 23.3999996, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  51. Part1.BottomSurface = Enum.SurfaceType.Smooth
  52. Part1.TopSurface = Enum.SurfaceType.Smooth
  53. Part1.Color = Color3.new(0.152941, 0.27451, 0.176471)
  54. Part1.Position = Vector3.new(-43.3999977, 0.460000128, 23.3999996)
  55. Part1.Orientation = Vector3.new(0, 90, 0)
  56. Part1.Color = Color3.new(0.152941, 0.27451, 0.176471)
  57. SpecialMesh2.Parent = Part1
  58. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=166887416"
  59. SpecialMesh2.Scale = Vector3.new(1.29999995, 1.5, 1.29999995)
  60. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  61. SpecialMesh2.Scale = Vector3.new(1.29999995, 1.5, 1.29999995)
  62. Sound3.Name = "Pin"
  63. Sound3.Parent = Part1
  64. Sound3.SoundId = "http://www.roblox.com/asset?id=168184001"
  65. Sound3.Volume = 1
  66. Sound4.Name = "Boom"
  67. Sound4.Parent = Part1
  68. Sound4.SoundId = "rbxasset://sounds/collide.wav"
  69. Sound4.Volume = 1
  70. Sound4.PlayOnRemove = true
  71. Animation5.Name = "ThrowAnimation"
  72. Animation5.Parent = Tool0
  73. Animation5.AnimationId = "http://www.roblox.com/Asset?ID=168160500"
  74. Configuration6.Name = "Configurations"
  75. Configuration6.Parent = Tool0
  76. NumberValue7.Name = "Cooldown"
  77. NumberValue7.Parent = Configuration6
  78. NumberValue7.Value = 3
  79. NumberValue8.Name = "GrenadeVelocity"
  80. NumberValue8.Parent = Configuration6
  81. NumberValue8.Value = 100
  82. NumberValue9.Name = "FuseTime"
  83. NumberValue9.Parent = Configuration6
  84. NumberValue9.Value = 5
  85. BoolValue10.Name = "ExplodeOnTouch"
  86. BoolValue10.Parent = Configuration6
  87. BoolValue10.Value = true
  88. NumberValue11.Name = "ExplosionRadius"
  89. NumberValue11.Parent = Configuration6
  90. NumberValue11.Value = 5
  91. LocalScript12.Name = "ClientScript"
  92. LocalScript12.Parent = Tool0
  93. table.insert(cors,sandbox(LocalScript12,function()
  94. local player = game.Players.LocalPlayer
  95. local mouse = player:GetMouse()
  96. local tool = script.Parent
  97. local config = tool:WaitForChild("Configurations")
  98.  
  99. local canThrow = true
  100.  
  101. tool.Equipped:connect(function()
  102. mouse.Icon = "rbxasset://textures/GunCursor.png"
  103. end)
  104.  
  105. tool.Unequipped:connect(function()
  106. mouse.Icon = ""
  107. end)
  108.  
  109. tool.Activated:connect(function()
  110. if canThrow then
  111. canThrow = false
  112. local throwAnimation = player.Character.Humanoid:LoadAnimation(tool.ThrowAnimation)
  113. throwAnimation:Play() -- Load and play the throwing animation
  114. throwAnimation.KeyframeReached:connect(function(keyframe) -- Wait 'til we reach a keyframe
  115. if keyframe == "tick" then -- if the keyframe is 'tick' then play the pin sound
  116. tool.Handle.Pin:Play()
  117. elseif keyframe == "throw" then -- otherwise, if it's 'throw,' tell the serverscript to throw our grenade
  118. tool.Throw:FireServer(mouse.Hit.p)
  119. throwAnimation:Stop()
  120. mouse.Icon = "rbxasset://textures/GunWaitCursor.png"
  121. end
  122. end)
  123. wait(config.Cooldown.Value)
  124. mouse.Icon = "rbxasset://textures/GunCursor.png"
  125. canThrow = true
  126. end
  127. end)
  128. end))
  129. RemoteEvent13.Name = "Throw"
  130. RemoteEvent13.Parent = Tool0
  131. Script14.Name = "ServerScript"
  132. Script14.Parent = Tool0
  133. table.insert(cors,sandbox(Script14,function()
  134. local tool = script.Parent
  135. local config = tool:WaitForChild("Configurations")
  136.  
  137. -- Uber l33t maths to calcluate the angle needed to throw a projectile a distance, given the altitude of the end point and the projectile's velocity
  138. function AngleOfReach(distance, altitude, velocity)
  139. local theta = math.atan((velocity^2 + math.sqrt(velocity^4 -196.2*(196.2*distance^2 + 2*altitude*velocity^2)))/(196.2*distance))
  140. if theta ~= theta then
  141. theta = math.pi/4
  142. end
  143. return(theta)
  144. end
  145.  
  146. -- A simple function to explode a specified part
  147. function Explode(part)
  148. local explosion = Instance.new("Explosion", workspace)
  149. explosion.Position = part.Position
  150. explosion.BlastRadius = config.ExplosionRadius.Value
  151. part:Destroy()
  152. end
  153.  
  154. script.Parent.Throw.OnServerEvent:connect(function(player, mousePosition)
  155. local handlePos = Vector3.new(tool.Handle.Position.X, 0, tool.Handle.Position.Z) -- remove Y from the equation, it's not needed
  156. local mousePos = Vector3.new(mousePosition.X, 0, mousePosition.Z) -- ditto
  157. local distance = (handlePos - mousePos).magnitude -- Get the distance between the handle and the mouse
  158. local altitude = mousePosition.Y - tool.Handle.Position.Y
  159. local angle = AngleOfReach(distance, altitude, config.GrenadeVelocity.Value) -- Calculate the angle
  160.  
  161. tool.Handle.Transparency = 1
  162. local grenade = tool.Handle:Clone()
  163. grenade.Parent = workspace
  164. grenade.Transparency = 0
  165. grenade.CanCollide = true
  166. grenade.CFrame = tool.Handle.CFrame
  167. grenade.Velocity = (CFrame.new(grenade.Position, Vector3.new(mousePosition.X, grenade.Position.Y, mousePosition.Z)) * CFrame.Angles(angle, 0, 0)).lookVector * config.GrenadeVelocity.Value -- Throwing 'n stuff, it probably didn't need to be this long
  168. spawn(function()
  169. if config.ExplodeOnTouch.Value then
  170. grenade.Touched:connect(function(hit)
  171. if hit.Parent ~= tool.Parent and hit.CanCollide then -- Make sure what we're hitting is collidable
  172. Explode(grenade)
  173. end
  174. end)
  175. else
  176.  
  177. wait(config.FuseTime.Value)
  178. Explode(grenade)
  179. end
  180. end)
  181. wait(config.Cooldown.Value)
  182. tool.Handle.Transparency = 0
  183. end)
  184. end))
  185. for i,v in pairs(mas:GetChildren()) do
  186. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  187. pcall(function() v:MakeJoints() end)
  188. end
  189. mas:Destroy()
  190. for i,v in pairs(cors) do
  191. spawn(function()
  192. pcall(v)
  193. end)
  194. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement