Help needed with Script

So basically, when you press the button it will log all players within a specific rank and up, but it only logs the player who presses the button. Here is the script, any help is appreciated.

local db4 = false
local function logAPI()
	if db4 == false then
		db4 = true
		local Staff = ""
		for _, Player in pairs(game.Players:GetPlayers()) do
			if Player:GetRankInGroup(group) >= logid then
				if Staff then
					Staff = Staff .. ", " .. Player.Name
					Frame.Other.LogAt.MainHost.LogAttendence.Text = "LOGGED"
					wait(3)
					Frame.Other.LogAt.MainHost.LogAttendence.Text = "COOLDOWN"

					game.ReplicatedStorage:FindFirstChild("sessionsFolder").logSessions:FireServer(Staff)


					wait(coolDown)
					Frame.Other.LogAt.MainHost.LogAttendence.Text = "LOG"
	
					db4 = false


				end

			end

		end
		
	end



end


Frame.Other.LogAt.MainHost.LogAttendence.MouseButton1Click:Connect(logAPI)