-- Emporerj

wait(1)
local Config = script.Parent:WaitForChild("Configuration")
function GetGlowParts()
	local GlowParts = {}
	for i,v in pairs(workspace:GetChildren())do
		if v.Name == "GlowPart" then
			table.insert(GlowParts,v)
		end
	end
	return GlowParts
end

function MakeGlow(Part)
	if #GetGlowParts()<Config.MaxParts.Value then
		local GlowPart = Instance.new("Part")
		GlowPart.Name = "GlowPart"
		GlowPart.Size = Vector3.new(1,1,1)
		GlowPart.CanCollide = false
		GlowPart.Anchored = true
		GlowPart.Transparency = 1
		local Glow = Instance.new("PointLight",GlowPart)
		Glow.Brightness = 5
		Glow.Range = 8
		Glow.Color = Config.GlowColor.Value
		GlowPart.CFrame = CFrame.new(Part.Position.X,script.Parent.Position.Y+script.Parent.Size.Y/2,Part.Position.Z)
		GlowPart.Parent = workspace
		game:GetService("Debris"):AddItem(GlowPart,0.3)
		for i=8,1,-1 do
			Glow.Range = i
			wait(0.1)
		end
	end
end

script.Parent.Touched:connect(function(Hit)
	local humanoid = Hit.Parent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		MakeGlow(humanoid.RootPart)
	elseif Config.PlayersOnly.Value == false then
		MakeGlow(Hit)
	end
end)
