--- RUNTIME ---


Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if Debounce == true then return end
	-- Clone script.Indicator to Character.Face, rotate, float via StudsOffset tween, and fade a BillboardGui damage indicator when the dummy is attacked
	
	-- Get the damage dealt
	local Damage = Humanoid.MaxHealth - Humanoid.Health
	
	Debounce = true
	Humanoid.Health += Damage
	Debounce = false
	
	-- Clone script.Indicator to Character.Face
	local Indicator = script.Indicator:Clone()
	Indicator.Enabled = true
	Indicator.Parent = Character.Face
	
	Indicator.TextLabel.Text = Damage
	
	-- Rotate the indicator a random amount of degrees
	Indicator.StudsOffset = Vector3.new(math.random(-15,15)/10,3,math.random(-50,50)/100)
	Indicator.TextLabel.Rotation = math.random(-30, 30)
	
	-- Float via StudsOffset tween and fade out over time with BillboardGui's TextTransparency property
	local Tween = TweenService:Create(Indicator, TweenInfo.new(3, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), {StudsOffset = Vector3.new(Indicator.StudsOffset.X, math.random(30,60)/10, Indicator.StudsOffset.Z)})
	Tween:Play()
	
	local Tween = TweenService:Create(Indicator.TextLabel, TweenInfo.new(3, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), {TextTransparency = 1})
	Tween:Play()
	local Tween = TweenService:Create(Indicator.TextLabel, TweenInfo.new(3, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), {TextStrokeTransparency = 1})
	Tween:Play()
	
	task.wait(3)
	
	Indicator:Destroy()
	
end)
