local I=1 local b=100 local V=script.Parent local p local h local t=false script.ClientThrow.OnServerEvent:connect(function(I)if not t and(V.Parent~=nil and(V.Parent.ClassName~="\066\097\099\107\112\097\099\107"and I==h))then t=true p:Play()end end)V.Equipped:connect(function()h=game.Players:GetPlayerFromCharacter(V.Parent)p=V.Parent.Humanoid:LoadAnimation(script.Animation)p.KeyframeReached:connect(function(I)if I=="\084\104\114\111\119"then game.ReplicatedStorage.Interactions.Client.CreateSnowball:FireAllClients(h.Character,V.Handle,(script.GetMouseHit:InvokeClient(h)-script.Parent.Handle.Position).Unit*b)V.Handle.Sound:Play()end end)p.Stopped:connect(function()t=false end)t=false end)V.Unequipped:connect(function()p:Stop()p:destroy()end)
-- General settings
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)
