--//Custom Functions\\--

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	debris:AddItem(Creator_Tag, 0.3)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function TextEffects(element, floatAmount, direction, style, duration)
	element:TweenPosition(UDim2.new(0, math.random(-40, 40), 0, -floatAmount), direction, style, duration)
	wait(0.5)

	for i = 1, 60 do
		element.TextTransparency = element.TextTransparency + 1/60
		element.TextStrokeTransparency = element.TextStrokeTransparency + 1/60
		wait(1/60)
	end

	element.TextTransparency = element.TextTransparency + 1
	element.TextStrokeTransparency = element.TextStrokeTransparency + 1
	element.Parent:Destroy()
end

function DynamicText(damage, criticalPoint, humanoid)
	local bill = Instance.new("BillboardGui", humanoid.Parent.Head)
	bill.Size = UDim2.new(0, 50, 0, 100) 
	local part = Instance.new("TextLabel", bill) 
	bill.AlwaysOnTop = true
	part.TextColor3 = Color3.fromRGB(255, 0, 0)
	part.Text = damage
	part.Font = Enum.Font.SourceSans
	part.TextStrokeTransparency = 0
	part.Size = UDim2.new(1, 0, 1, 0) 
	part.Position = UDim2.new(0, 0, 0, 0) 
	part.BackgroundTransparency = 1
	bill.Adornee = bill.Parent
			
	if damage < criticalPoint then
		part.TextSize = 28
		part.TextColor3 = Color3.new(1, 0, 0)
	elseif damage >= criticalPoint then
		part.TextSize = 32
		part.TextColor3 = Color3.new(1, 1, 0)
	end 
	
	spawn(function()
		TextEffects(part, 85, Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.75)
	end)
end

function DamageAndTagHumanoid(player, humanoid, damage)
	hit:FireClient(player)
	UntagHumanoid(handle)
	print("My Player =", player.Name)
	local brd = player:FindFirstChild("leaderstats")
	if brd then
		brd["Points"].Value = brd["Points"].Value + 1
	end
	humanoid:TakeDamage(damage) TagHumanoid(humanoid, player)
end
