--[[

repeat until not script.Parent.Touched:wait():IsDescendantOf(game.Players[script.Parent.Name].Character) 
script.Parent.Throw:Stop()

local vel = script.Parent.Velocity
local trace = Ray.new(script.Parent.Position,vel*10)
local hit,pos = workspace:FindPartOnRay(trace,game.Players[script.Parent.Name].Character)

--]]


if script.Name~="Explode" then
	
if hit~=nil and hit.Anchored and hit.CanCollide and hit.Transparency<1 then

script.Parent.Anchored = true
script.Parent.CFrame = CFrame.new(pos,pos+vel)*CFrame.Angles(math.pi/-2,0,0)
script.Parent.Stick:Play()

wait(10)
for i=0,1,0.02 do
	wait(0.05)
	script.Parent.Transparency = i
end
elseif hit~=nil and hit.Parent~=nil then
	if hit.Parent.className=="Hat" and hit.Parent.Parent:FindFirstChild("Head")~=nil then hit=hit.Parent.Parent.Head end
	if hit.Parent:FindFirstChild("Humanoid")~=nil and hit.Parent.Humanoid.Health>0 then
		hit.Parent.Humanoid:TakeDamage(100)
		local s = script.Parent.Kill
		s.Parent = hit.Parent:FindFirstChild("Head")
		s:Play()
		hit.Velocity = vel.unit*15
		game.Debris:AddItem(s,2)
	end
end
script.Parent:Remove()

else
	local e = Instance.new("Explosion")
	e.Hit:connect(function(part,dist)
		if part.Parent~=nil and part.Parent:FindFirstChild("Humanoid")~=nil then
			if part.Parent.Name~=script.Parent.Name then
				 part.Parent.Humanoid:TakeDamage(100)
			end
		end
	end)
	e.Position = pos
	e.BlastPressure = 100
	e.DestroyJointRadiusPercent = 0
	e.Parent = workspace
	--script.Parent.Parent = nil
	wait()
	script.Parent:Remove()
end
