Connection running before the code before it

The function connected to an event is being called before the event is even connected.

	self._ButtonData[Button.Name] = {
		 ["Coins"] = Button:WaitForChild("Coins").Value;
		 ["Gems"] = Button:WaitForChild("Gems").Value;
		 ["RequiredLevel"] = Button:WaitForChild("Level").Value;
		 ["ObjectName"] = Button:WaitForChild("ItemName").Value;
		 ["ObjectLevel"] = 
         self._TycoonService:GetNextObjectLevel(Button.Name):expect();
	}
	print("b4", Button.Name)
	local connected = true
	proxPrompt.PromptShown:Connect(function()
		print(connected)
		print("after", Button.Name)
		local buttonData = self._ButtonData[Button.Name]["ObjectName"]
    end
--output: 
  00:26:57.760  true  -  Client - ButtonController:48
  00:26:57.760  after 69FD6A83-CF33-4AE9  -  Client - ButtonController:50
  00:26:57.761  Players.keith_220.PlayerScripts.Controllers.ButtonController:52: attempt to index nil with 'ObjectName'  -  Client - ButtonController:52
  00:26:57.791  b4 69FD6A83-CF33-4AE9  -  Client - ButtonController:44

The first line in the output is true which is the variable I set before the connection.
The second line is what comes immediatly after it.
Both of these print statements run before the first print statement (print("b4", Button.Name)) even though the first print statement is supposed to run before the connection is even made.


I wouldn’t normally turn to the devforum for help, I usually figure out stuff on my own, but I’ve spent hours trying to figure this out already. Any help would be appreciated!