-- Hide after we're done
overlay.Position = UDim2.new(10, 0, 0, 0)
end



local Camera=game.Workspace.CurrentCamera
			function RotCamera(RotX, RotY, SmoothRot, Duration)
	spawn(function()
		if SmoothRot then
			local TweenIndicator = nil
			local NewCode = math.random(-1e9, 1e9)
			if (not Camera:FindFirstChild("TweenCode")) then
				TweenIndicator = Instance.new("IntValue")
				TweenIndicator.Name = "TweenCode"
				TweenIndicator.Value = NewCode
				TweenIndicator.Parent = Camera
			else
				TweenIndicator = Camera.TweenCode
				TweenIndicator.Value = NewCode
			end
			
			local Step = math.min(1.5 / math.max(Duration, 0), 90)
			local X = 0
			while true do
				local NewX = X + Step
				X = (NewX > 90 and 90 or NewX)
				if TweenIndicator.Value ~= NewCode then break end
				if Camera.CoordinateFrame.lookVector.y>0.985 then
					break 
				end
				local CamRot = Camera.CoordinateFrame - Camera.CoordinateFrame.p
				local CamDist = (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude
				local NewCamCF = CFrame.new(Camera.Focus.p) * CamRot * CFrame.Angles(RotX / (90 / Step), 0, 0)
				Camera.CoordinateFrame = CFrame.new(NewCamCF.p, NewCamCF.p + NewCamCF.lookVector) * CFrame.new(0, 0, CamDist)
				print(X)
				if X == 90 then break end
				game:GetService("RunService").RenderStepped:wait()
			end
			
			if TweenIndicator.Value == NewCode then
				TweenIndicator:Destroy()
			end
		else
			local CamRot = Camera.CoordinateFrame - Camera.CoordinateFrame.p
			local CamDist = (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude
			local NewCamCF = CFrame.new(Camera.Focus.p) * CamRot * CFrame.Angles(RotX, RotY, 0)
			Camera.CoordinateFrame = CFrame.new(NewCamCF.p, NewCamCF.p + NewCamCF.lookVector) * CFrame.new(0, 0, CamDist)
		end
	end)
end

function RAND(Min, Max, Accuracy)
	local Inverse = 1 / (Accuracy or 1)
	return (math.random(Min * Inverse, Max * Inverse) / Inverse)
end


function ShakeCam()
	local CurrentRecoil =  math.random(1,4)
	local RecoilX = math.rad(CurrentRecoil * RAND(1, 1.5, 0.1))
	local RecoilY = math.rad(CurrentRecoil * RAND(-2, 2, 0.1))
	RotCamera(RecoilX, RecoilY, true, 0.06)
	wait(.1)
	RotCamera(-RecoilX, -RecoilY, true, 0.06)
end


function healthGUIUpdate(health)
damagedone=lastHealth-health
if damagedone > 0 then
if game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") and game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator") then
if game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator").Value then
if game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator").Value.Character then
if game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator").Value.Character:FindFirstChild("Torso") then
if game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator").Value ~= game.Players.LocalPlayer then

local vel = CFrame.new(game.Players.LocalPlayer.Character.Humanoid:FindFirstChild("creator").Value.Character.Torso.Position,game.Players.LocalPlayer.Character.Torso.Position).lookVector
for i=1,10 do
 game.Players.LocalPlayer.Character.Torso.Velocity = vel * math.random(30,46)
end


end
end
end
end
end
ShakeCam()
end


if humanoid.Health ~= humanoid.MaxHealth and damagedone>0 then
	
delay(0,function()

AnimateHurtOverlay()
end)
end

lastHealth = health



end

	
	
	
function GetSurfaceNormal(part,point) 
	local p = part.CFrame:toObjectSpace(CFrame.new(point)).p
	if (math.abs(p.X)>=part.Size.X/2-.1) then
		return (part.CFrame*Vector3.new(p.X/math.abs(p.X),0,0)-part.CFrame.p)
	elseif (math.abs(p.Y)>=part.Size.Y/2-.1) then
		return (part.CFrame*Vector3.new(0,p.Y/math.abs(p.Y),0)-part.CFrame.p)
	elseif (math.abs(p.Z)>=part.Size.Z/2-.1) then
		return (part.CFrame*Vector3.new(0,0,p.Z/math.abs(p.Z))-part.CFrame.p)
	end
end


function splatterBlood(origin,humanoid,dmg)