Frag Grenade
Frag Grenade
Frag Grenade
M67 Fragmentation Grenade. Pull the pin / Drop it in / Let it wash away their sins.
--]]
Player = game.Players.LocalPlayer
Char = Player.Character
animate = Char:findFirstChild("Animate")
if animate then
animate:Destroy()
end
Name = "M67 Frag"
selected = false
Button1Down = false
thrown = false
function makeParts(format)
local grenade = Instance.new("Model")
grenade.Name = Name
grenade.Parent = Player.Character
local pm = Instance.new("Part")
pm.Name = "Handle"
pm.formFactor = "Symmetric"
pm.Size = Vector3.new(1, 1, 1)
pm.BrickColor = BrickColor.new("Camo")
pm.Locked = true
pm.TopSurface = 0
pm.BottomSurface = 0
pm.Parent = grenade
local m = Instance.new("SpecialMesh")
m.MeshType = "Sphere"
m.Scale = Vector3.new(0.6, 0.7, 0.6)
m.Parent = pm
local w = Instance.new("Weld")
w.Part0 = pm
if format == "hand" then
w.Part1 = Player.Character:FindFirstChild("Right Arm")
w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90),
0, math.rad(90))
w.C1 = CFrame.new()
elseif format == "holster" then
w.Part1 = Player.Character:FindFirstChild("Torso")
w.C0 = CFrame.new(-0.5, 0.68, 0.55) * CFrame.fromEulerAnglesXYZ(0, 0,
math.rad(-6))
w.C1 = CFrame.new()
grenade.Name = Name.. " (Holstered)"
end
w.Parent = pm
local s = Instance.new("Sound")
s.Name = "Explode"
s.SoundId = "rbxasset://sounds\\collide.wav"
s.Volume = 1
s.Pitch = 1
s.Looped = false
s.Parent = pm
local s = Instance.new("Sound")
s.Name = "Ready"
s.SoundId = "http://www.roblox.com/Asset/?id=2697295"
s.Volume = 1
s.Pitch = 2
s.Looped = false
s.Parent = pm
local s = Instance.new("Sound")
s.Name = "Pin"
s.SoundId = "http://www.roblox.com/Asset/?id=10209636"
s.Volume = 1
s.Pitch = 2
s.Looped = false
s.Parent = pm
local p = Instance.new("Part")
p.Name = "Pin Holder"
p.formFactor = "Symmetric"
p.Size = Vector3.new(1, 1, 1)
p.BrickColor = BrickColor.new("Dark stone grey")
p.CanCollide = false
p.Transparency = 0
p.Locked = true
p.TopSurface = 0
p.BottomSurface = 0
p.Parent = grenade
local m = Instance.new("CylinderMesh")
m.Scale = Vector3.new(0.22, 0.2, 0.22)
m.Parent = p
local w = Instance.new("Weld")
w.Part0 = p
w.Part1 = pm
w.C0 = CFrame.new(0, -0.5, 0)
w.C1 = CFrame.new()
w.Parent = p
local p = Instance.new("Part")
p.Name = "Pin Holder 2"
p.formFactor = "Symmetric"
p.Size = Vector3.new(1, 1, 1)
p.BrickColor = BrickColor.new("Camo")
p.CanCollide = false
p.Transparency = 0
p.Locked = true
p.TopSurface = 0
p.BottomSurface = 0
p.Parent = grenade
local m = Instance.new("CylinderMesh")
m.Scale = Vector3.new(0.2, 0.2, 0.2)
m.Parent = p
local w = Instance.new("Weld")
w.Part0 = p
w.Part1 = pm
w.C0 = CFrame.new(0, -0.3, 0)
w.C1 = CFrame.new()
w.Parent = p
local p = Instance.new("Part")
p.Name = "Clamp"
p.formFactor = "Symmetric"
p.Size = Vector3.new(1, 1, 1)
p.BrickColor = BrickColor.new("Black")
p.CanCollide = false
p.Transparency = 0
p.Locked = true
p.TopSurface = 0
p.BottomSurface = 0
p.Parent = grenade
local m = Instance.new("SpecialMesh")
m.MeshType = "FileMesh"
m.MeshId = "http://www.roblox.com/asset/?id=3270017"
m.Scale = Vector3.new(0.45, 0.5, 0.8)
m.Parent = p
local w = Instance.new("Weld")
w.Part0 = p
w.Part1 = pm
w.C0 = CFrame.new(0.12, -0.18, 0)
w.C1 = CFrame.new()
w.Parent = p
local pm2 = Instance.new("Part")
pm2.Name = "Pin"
pm2.formFactor = "Symmetric"
pm2.Size = Vector3.new(1, 1, 1)
pm2.BrickColor = BrickColor.new("Dark stone grey")
pm2.Transparency = 0
pm2.Locked = true
pm2.TopSurface = 0
pm2.BottomSurface = 0
pm2.Parent = grenade
local m = Instance.new("SpecialMesh")
m.MeshType = "FileMesh"
m.MeshId = "http://www.roblox.com/asset/?id=3270017"
m.Scale = Vector3.new(0.2, 0.2, 0.4)
m.Parent = pm2
local w = Instance.new("Weld")
w.Part0 = pm2
w.Part1 = pm
w.C0 = CFrame.new(0.15, -0.6, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90),
0)
w.C1 = CFrame.new()
w.Parent = pm2
end
function removeParts(format)
if format == "hand" then
if Player.Character:FindFirstChild(Name) ~= nil then
Player.Character[Name]:Remove()
end
elseif format == "holster" then
if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
Player.Character[Name.. " (Holstered)"]:Remove()
end
end
end
function Weld(x, y)
local weld = Instance.new("Weld")
weld.Part0 = x
weld.Part1 = y
CJ = CFrame.new(x.Position)
C0 = x.CFrame:inverse() * CJ
C1 = y.CFrame:inverse() * CJ
weld.C0 = C0
weld.C1 = C1
weld.Parent = x
end
function tagHumanoid(humanoid)
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = Player
tag.Parent = humanoid
local tag = Instance.new("StringValue")
tag.Name = "creatorType1"
tag.Value = Name
tag.Parent = humanoid
local tag = Instance.new("StringValue")
tag.Name = "creatorType2"
tag.Value = "blown up"
tag.Parent = humanoid
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:FindFirstChild("creator")
if tag ~= nil then
tag:Remove()
end
local tag = humanoid:FindFirstChild("creatorType1")
if tag ~= nil then
tag:Remove()
end
local tag = humanoid:FindFirstChild("creatorType2")
if tag ~= nil then
tag:Remove()
end
end
end
function fire(v)
if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then
Player.Character[Name].Handle.Weld:Remove() end
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.velocity = v * 75
bodyVelocity.Parent = Player.Character[Name].Handle
wait(0.1)
bodyVelocity:Remove()
end
function onButton1Down(mouse)
if selected == false then return end
if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and
thrown ~= true then
if Player.Character[Name]:FindFirstChild("Handle") == nil then return
end
if Player.Character[Name]:FindFirstChild("Pin") == nil then return end
Button1Down = true
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
if Player.Character[Name].Pin:FindFirstChild("Weld") ~= nil then
Player.Character[Name].Pin.Weld:Remove() end
Player.Character[Name].Handle.Pin:Play()
Player.Character[Name].Handle.CanCollide = true
wait(0.2)
Player.Character[Name].Handle.Ready:Play()
coroutine.resume(coroutine.create(function()
wait(3)
if Player.Character:FindFirstChild(Name) ~= nil then
if Player.Character[Name]:FindFirstChild("Handle") ~= nil
then
local e = Instance.new("Explosion")
e.BlastPressure = 1000000
e.BlastRadius = 20
e.Position = Player.Character[Name].Handle.Position
e.Parent = game:GetService("Workspace")
e.Hit:connect(function(hit) if
hit.Parent:FindFirstChild("Humanoid") ~= nil then tagHumanoid(hit.Parent.Humanoid)
delay(1, function() untagHumanoid(hit.Parent.Humanoid) end) end end)
Player.Character[Name].Handle.Explode:Play()
Player.Character[Name].Handle.Transparency = 1
Player.Character[Name].Handle.CanCollide = false
end
end
wait()
if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
Player.Character.WeaponActivated:Remove()
end
thrown = false
Button1Down = false
selected = true
onDeselected(mouse)
removeParts("holster")
script.Parent:Remove()
end))
end
end
function onButton1Up(mouse)
if selected == false then return end
if Button1Down == true and thrown ~= true then
thrown = true
mouse.Icon = "rbxasset://textures\\GunCursor.png"
SetSpeed(1, 2, Player.Character)
SetAngle(1, 0, Player.Character)
EnableLimb(1, Player.Character)
fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
end
Button1Down = false
end
function onSelected(mouse)
if selected == true then return end
selected = true
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown ==
true do
if Player.Character.WeaponActivated.Value == nil then break end
if Player.Character.WeaponActivated.Value.Parent == nil then break end
wait()
end
mouse.Icon = "rbxasset://textures\\GunCursor.png"
removeParts("holster")
makeParts("hand")
local weapon = Instance.new("ObjectValue")
weapon.Name = "WeaponActivated"
weapon.Value = script.Parent
weapon.Parent = Player.Character
DisableLimb(1, Player.Character)
SetAngle(1, math.rad(200), Player.Character)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() onButton1Up(mouse) end)
mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
end
function onDeselected(mouse)
if selected == false then return end
selected = false
while Button1Down == true or thrown == true do
wait()
end
if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
if Player.Character.WeaponActivated.Value == script.Parent then
Player.Character.WeaponActivated:Remove()
end
end
while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
if Player.Character.WeaponActivated.Value == nil then break end
if pcall(function() if Player.Character.WeaponActivated.Value.Parent ==
nil then return true end end) then break end
wait()
end
removeParts("hand")
makeParts("holster")
SetAngle(1, 0, Player.Character)
EnableLimb(1, Player.Character)
end