How to return a value from an event connection to the function above it?

Let’s say I have the following code:

function playerResponse(): number
	SomeEvent:Connect(function(player, response)
		return response 
	end)
end

local result = playerResponse() --nil

This code should return nil instead of a response, so the question is, how can I return the event value to the above function the moment its ready?(so instead of nil it prints the response)

I believe you can just use SomeEvent:Wait() just like player.CharacterAdded:Wait() is used to get the character if it hasnt loaded yet.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.