--[[
	
	The golden hit detection script! For experimental mode, mainly.
	Rather than detect superball and slingshot hits by having the 
	ball look for a player in any object it touches, this script
	makes the player check if any object it touches is a ball or
	slingshot projectile. It works better because it has all your 
	body parts (about 6 or 7 parts for R6, many more for R15) 
	checking for hits, rather than just one part!
	
--]]


local ds2=true
local dp2=true

function dmg(Part)
	script.Parent.Humanoid:TakeDamage(Part.damage.Value)
	script.Parent.Humanoid.Died:connect(function()
		if not script.Parent.Humanoid:FindFirstChild("creator") then
			if Part:FindFirstChild("creator") then
				if Part:WaitForChild("creator",1).Value:FindFirstChild("leaderstats") then
					Part:WaitForChild("creator",1):Clone().Parent=script.Parent.Humanoid
				end
			end
		end
	end)
end

script.Parent:WaitForChild("Humanoid",1).Touched:connect(function(Part,Limb)
	local player=game.Players:GetPlayerFromCharacter(script.Parent)
	if Part.Name=="Cannon Shot" then
		if ds2==true then
			ds2=false
			if Part:WaitForChild("creator",1).Value~=player then
				if script.Parent.Humanoid.Health~=0 then
					if player:WaitForChild("AntiTeamKill",1).Value==true then
						if player.TeamColor~=Part:WaitForChild("creator",1).Value.TeamColor then
							dmg(Part)
						end
					else
						dmg(Part)
					end
				end
			end
			wait(1/30)
			ds2=true
		end
	elseif Part.Name=="Pellet" then
		if dp2==true then
			ds2=false
			if Part:WaitForChild("creator",1).Value~=player then
				if script.Parent.Humanoid.Health~=0 then
					if player:WaitForChild("AntiTeamKill",1).Value==true then
						if player.TeamColor~=Part:WaitForChild("creator",1).Value.TeamColor then
							dmg(Part)
						end
					else
						dmg(Part)
					end
				end
			end
			wait(.2)
			ds2=true
		end
	end
end)
