Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- flashbang = Instance.new("Tool",game.Players.meunumbertwo.Backpack)
- flashbang.Name = "FlashBang"
- handle = Instance.new("Part",flashbang)
- handle.FormFactor = Enum.FormFactor.Symmetric
- handle.TopSurface = Enum.SurfaceType.Smooth
- handle.Size = Vector3.new(1,1,1)
- handle.Name = "Handle"
- handle.CFrame = CFrame.new(-68,0.49829688668251,-7) * CFrame.Angles(5.8255799369435e-018, 1.5707963705063, 0)
- handle.BrickColor = BrickColor.new("Earth green")
- handle.Friction = 0.30000001192093
- handle.Shape = Enum.PartType.Ball
- handle.BottomSurface = Enum.SurfaceType.Smooth
- creator = Instance.new("ObjectValue",handle)
- creator.Name = "creator"
- fire = Instance.new("Fire",handle)
- fire.Enabled = false
- fire.Heat = 0
- fire.Color = Color3.new(1, 1, 1)
- fire.SecondaryColor = Color3.new(1, 1, 1)
- fire.Size = 30
- boom = Instance.new("Sound",handle)
- boom.Pitch = 2
- boom.Name = "Boom"
- boom.Volume = 1
- boom.SoundId = "http://www.roblox.com/asset/?id=25270310"
- smoke = Instance.new("Smoke",handle)
- smoke.Enabled = false
- smoke.RiseVelocity = 0
- smoke.Size = 100
- sparkles = Instance.new("Sparkles",handle)
- sparkles.Enabled = false
- sparkles.SparkleColor = Color3.new(1, 1, 1)
- mesh = Instance.new("SpecialMesh",handle)
- mesh.Scale = Vector3.new(0.60000002384186,0.69999998807907,0.60000002384186)
- mesh.MeshId = "http://www.roblox.com/asset/?id=16975131"
- mesh.TextureId = "http://www.roblox.com/asset/?id=16975111"
- mesh.MeshType = Enum.MeshType.FileMesh
- counter = Instance.new("NumberValue",flashbang)
- counter.Name = "Counter"
- counter.Value = 7
- blind = Instance.new("GuiMain",flashbang)
- blind.Name = "Blind"
- blur = Instance.new("ImageLabel",blind)
- blur.Size = UDim2.new(100000000, 0, 1000000, 2000)
- blur.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
- blur.Name = "Blur"
- blur.BackgroundColor3 = Color3.new(1, 1, 1)
- local Tool = flashbang;
- enabled = true
- function onButton1Down(mouse)
- if not enabled then
- return
- end
- enabled = false
- mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
- wait(1)
- mouse.Icon = "rbxasset://textures\\GunCursor.png"
- enabled = true
- end
- function Mode(k)
- if (k == "r") then
- Tool.Counter.Value = 1
- end
- if (k == "e") then
- Tool.Counter.Value = 4
- end
- if (k == "q") then
- Tool.Counter.Value = 7
- end
- if (k == "f") then
- Tool.Counter.Value = 11
- end
- end
- function onEquippedLocal(mouse)
- if mouse == nil then
- print("Mouse not found")
- return
- end
- mouse.Icon = "rbxasset://textures\\GunCursor.png"
- mouse.Button1Down:connect(function() onButton1Down(mouse) end)
- mouse.KeyDown:connect(Mode)
- end
- Tool.Equipped:connect(onEquippedLocal)
- print("Wearing Off")
- local Tool = flashbang
- local ToolName = Tool.Name
- local VELOCITY = 70
- local armed = false
- local db = false
- function Throw(mouse_pos)
- local vCharacter = Tool.Parent
- local vPlayer = game.Players:playerFromCharacter(vCharacter)
- local head = vCharacter:findFirstChild("Head")
- if head == nil then return end
- local dir = mouse_pos - head.Position
- dir = computeDirection(dir)
- local launch = head.Position + 5 * dir
- local delta = mouse_pos - launch
- local dy = delta.y
- local new_delta = Vector3.new(delta.x, 0, delta.z)
- delta = new_delta
- local dx = delta.magnitude
- local unit_delta = delta.unit
- -- acceleration due to gravity in RBX units
- local g = (-9.81 * 20)
- local theta = computeLaunchAngle( dx, dy, g)
- local vy = math.sin(theta)
- local xz = math.cos(theta)
- local vx = unit_delta.x * xz
- local vz = unit_delta.z * xz
- Tool.Parent = workspace
- local missile = Tool.Handle
- missile.Position = launch
- missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = vPlayer
- creator_tag.Name = "creator"
- creator_tag.Parent = missile
- end
- function computeLaunchAngle(dx,dy,grav)
- local g = math.abs(grav)
- local inRoot = (VELOCITY^4) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
- if inRoot <= 0 then
- return .25 * math.pi
- end
- local root = math.sqrt(inRoot)
- local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)
- local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
- local answer1 = math.atan(inATan1)
- local answer2 = math.atan(inATan2)
- if answer1 < answer2 then return answer1 end
- return answer2
- end
- function computeDirection(vec)
- local lenSquared = vec.magnitude * vec.magnitude
- local invSqrt = 1 / math.sqrt(lenSquared)
- return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
- end
- Tool.Enabled = true
- function onActivated()
- if (armed) then
- local character = Tool.Parent;
- local humanoid = character.Humanoid
- if humanoid == nil then
- print("Humanoid not found")
- return
- end
- local targetPos = humanoid.TargetPoint
- Throw(targetPos)
- else
- Arm()
- end
- end
- function Arm()
- local count = Tool.Counter.Value
- print("Arming grenade...")
- armed = true
- coroutine.resume(coroutine.create(function()
- for i = 1,count do
- Tool.Name = ToolName.. " [" ..count.. "]"
- print(count.. "...")
- wait(1)
- count = count - 1
- end
- for i,p in pairs(game.Players:children()) do
- if (p.Character) and (p.Character:findFirstChild("Torso")) and ((p.Character.Torso.Position - Tool.Handle.Position).magnitude < 50) then
- local stun = Tool.Blind:Clone()
- stun.Parent = p.PlayerGui
- wait()
- end
- end
- print("BOOM!")
- Tool.Handle.Boom:Play()
- Tool.Handle.Fire.Enabled = true
- Tool.Handle.Smoke.Enabled = true
- Tool.Handle.Sparkles.Enabled = true
- wait(0.4)
- Tool:Remove()
- end))
- end
- function Give(part)
- wait()
- if (part == nil) then return end
- if (part.Parent:findFirstChild("Humanoid")) and (part.Parent.Humanoid.Health > 0) and (not db) then
- db = true
- Tool.Parent = part.Parent
- wait(0.5)
- db = false
- end
- end
- Tool.Activated:connect(onActivated)
- Tool.Handle.Touched:connect(Give)
- local light = flashbang
- wait(2)
- while true do
- wait(4)
- light.Transparency = .1
- wait(1)
- light.Transparency = .2
- wait(1)
- light.Transparency = .2
- wait(1)
- light.Transparency = .3
- wait(1)
- light.Transparency = .4
- wait(1)
- light.Transparency = .5
- wait(1)
- light.Transparency = .6
- wait(1)
- light.Transparency = .7
- wait(1)
- light.Transparency = .8
- wait(1)
- light.Transparency = .9
- wait(1)
- light.Transparency = 1
- wait(1)
- light.Parent:Remove()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement