local O=1 local D=100 local g=script.Parent local Y local B local f=false script.ClientThrow.OnServerEvent:connect(function(O)if not f and(g.Parent~=nil and(g.Parent.ClassName~="\066\097\099\107\112\097\099\107"and O==B))then f=true Y:Play()end end)g.Equipped:connect(function()B=game.Players:GetPlayerFromCharacter(g.Parent)Y=g.Parent.Humanoid:LoadAnimation(script.Animation)Y.KeyframeReached:connect(function(O)if O=="\084\104\114\111\119"then game.ReplicatedStorage.Interactions.Client.CreateSnowball:FireAllClients(B.Character,g.Handle,(script.GetMouseHit:InvokeClient(B)-script.Parent.Handle.Position).Unit*D)g.Handle.Sound:Play()end end)Y.Stopped:connect(function()f=false end)f=false end)g.Unequipped:connect(function()Y:Stop()Y:destroy()end)

local COOLDOWN = 1
local THROW_SPEED = 100

local tool = script.Parent

local anim
local toolPlr
local debounce = false

script.ClientThrow.OnServerEvent:connect(function(plr)
	
	-- Check if tool is equipped and correct player
	if not debounce and tool.Parent ~= nil and tool.Parent.ClassName ~= "Backpack" and plr == toolPlr then
		debounce = true
		
		-- Play animation
		anim:Play()
		
	end
	
end)

tool.Equipped:connect(function()
	
	-- Set tool player
	toolPlr = game.Players:GetPlayerFromCharacter(tool.Parent)
	
	-- Load animation
	anim = tool.Parent.Humanoid:LoadAnimation(script.Animation)
	anim.KeyframeReached:connect(function(keyframe)
		
		-- Check what frame
		if keyframe == "Throw" then
			
			-- Create snowball
			game.ReplicatedStorage.Interactions.Client.CreateSnowball:FireAllClients(toolPlr.Character, tool.Handle, (script.GetMouseHit:InvokeClient(toolPlr) - script.Parent.Handle.Position).Unit * THROW_SPEED)
			
			-- Play sound
			tool.Handle.Sound:Play()
			
		end
		
	end)
	anim.Stopped:connect(function()
		debounce = false
	end)
	
	-- Reset just in case
	debounce = false
	
end)

tool.Unequipped:connect(function()
	
	-- Stop animation
	anim:Stop()
	anim:destroy()
	
end)
