---------------------------------------------

local alreadythrown=false

local HoldAnim, ThrowAnim;
function UUU()
	if script.Parent.Anim.Value==false then
if alreadythrown then 
	return
end
	if game.Workspace.Preparation.Value==true then return end
	if script.Parent.Enabled==false then return end

HoldAnim:Play()

script.Parent.Anim.Value=true
end
end

function THROW(short)
if game.Workspace.Preparation.Value==true then return end
		if script.Parent.Enabled==false then return end
			if script.Parent.Anim.Value==true  then
				if alreadythrown then
				return
				end
				alreadythrown=true
		--we track the reload time like this so that the player can't fire faster with
		--rapid dis / re-equipping, which will actually be common usage with this gear.
					HoldAnim:Stop(0)
				if short and short==true then
				local dent=Instance.new("IntValue")
				dent.Parent=script.Parent
				dent.Name="Short"
				end
			script.Parent.Anim.Value=false
			
			ThrowAnim:Play(0,1,1)
			script.Parent.Handle.Throw:Play()
			wait(0.2)
			--
			script.Parent.SpawnGrenade:FireServer(game.Players.LocalPlayer.Character.Head.CFrame,game.Players.LocalPlayer.Character.Humanoid.TargetPoint,short)
			


end
end
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local idle=game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent:WaitForChild("Idle"))
Tool.Equipped:connect(function(mouse)
	local button1=false
local button2=false
	idle:Play()
	Character = Tool.Parent
	Player = game.Players:GetPlayerFromCharacter(Character)

	local HoldAnimSrc = WaitFor(Tool).HoldAnim()
	HoldAnimSrc.AnimationId = 'http://www.roblox.com/asset/?id=88743592'
	local ThrowAnimSrc = WaitFor(Tool).ThrowAnim()
	ThrowAnimSrc.AnimationId = 'http://www.roblox.com/asset/?id=88743566'

	HoldAnim = Character.Humanoid:LoadAnimation(HoldAnimSrc)
	ThrowAnim = Character.Humanoid:LoadAnimation(ThrowAnimSrc)
script.Parent.Enabled=false
wait(0.6)
script.Parent.Enabled=true
	--setup first anim / cursor cycle
mouse.Button1Down:connect(function()
	button1=true
UUU()
end)
mouse.Button2Down:connect(function()
	button2=true
UUU()
end)
	mouse.Button1Up:connect(function()
button1=false
if button1==false and button2==false then
		THROW(false)
		end
	end)
	mouse.Button2Up:connect(function()
button2=false
if button1==false and button2==false then
		THROW(true)
		end
end)
end)
Tool.Unequipped:connect(function()

	script.Parent.Anim.Value=false
	if idle then
		idle:Stop()
	end
	script.Parent.Anim.Value=false
	if ThrowAnim then
		ThrowAnim:Stop()
	end
	if HoldAnim then
		HoldAnim:Stop()
	end
end)
