--[=[
	Invokes the function once at the given event, unless the cancel callback is called.

	@param event Signal | RBXScriptSignal
	@param func function -- Function to call
	@return function -- Call this function to cancel call
]=]

function StepUtils.onceAtEvent(event, func)
	assert(type(func) == "function", "Bad func")

	local conn
	local function cleanup()
		if conn then
			conn:Disconnect()
			conn = nil
		end
	end

	conn = event:Connect(function(...)
		cleanup()
		func(...)
	end)

	return cleanup
end

return StepUtils
